PHP: dBase Functions - Manual
PHP  
downloads | documentation | faq | getting help | mailing lists | | php.net sites | links | my php.net 
search for in the  
<timedbase_add_record>
view the version of this page
Last updated: Thu, 15 Jul 2004

XVIII. dBase Functions

�vod

These functions allow you to access records stored in dBase-format (dbf) databases.

There is no support for indexes or memo fields. There is no support for locking, too. Two concurrent webserver processes modifying the same dBase file will very likely ruin your database.

dBase files are simple sequential files of fixed length records. Records are appended to the end of the file and delete records are kept until you call dbase_pack().

We recommend that you do not use dBase files as your production database. Choose any real SQL server instead; MySQL or Postgres are common choices with PHP. dBase support is here to allow you to import and export data to and from your web database, because the file format is commonly understood by Windows spreadsheets and organizers.

Instalace

In order to enable the bundled dbase library and to use these functions, you must compile PHP with the --enable-dbase option.

Konfigurace b�hu

Toto roz���en� nem� definov�no ��dn� konfigura�n� direktivy.

Typy prost�edk�

Toto roz���en� nem� definov�n ��dn� typ prost�edku (resource).

P�eddefinovan� konstanty

Toto roz���en� nem� definov�ny ��dn� konstanty.

Obsah
dbase_add_record -- Add a record to a dBase database
dbase_close -- Close a dBase database
dbase_create -- Creates a dBase database
dbase_delete_record -- Deletes a record from a dBase database
dbase_get_header_info -- Get the header info of a dBase database
dbase_get_record_with_names --  Gets a record from a dBase database as an associative array
dbase_get_record -- Gets a record from a dBase database
dbase_numfields --  Find out how many fields are in a dBase database
dbase_numrecords --  Find out how many records are in a dBase database
dbase_open -- Opens a dBase database
dbase_pack -- Packs a dBase database
dbase_replace_record -- Replace a record in a dBase database


add a note add a note User Contributed Notes
dBase Functions
Hadi Rusiah / deegos at yahoo dot com
08-May-2004 05:33
If you are using PHP < 5, you can use this function to retrieve dbf header

<?
function get_dbf_header($dbfname) {
  
$fdbf = fopen($dbfname,'r');

  
$dbfhdrarr = array();
  
$buff32 = array();
  
$i = 1;
  
$goon = true;

   while (
$goon) {
     if (!
feof($fdbf)) {
        
$buff32 = fread($fdbf,32);
         if (
$i > 1) {
           if (
substr($buff32,0,1) == chr(13)) {
              
$goon = false;
           } else {
              
$pos = strpos(substr($buff32,0,10),chr(0));
              
$pos = ($pos == 0?10:$pos);

              
$fieldname = substr($buff32,0,$pos);
              
$fieldtype = substr($buff32,11,1);
              
$fieldlen = ord(substr($buff32,16,1));
              
$fielddec = ord(substr($buff32,17,1));

array_push($dbfhdrarr, array($fieldname,$fieldtype,$fieldlen,$fielddec));

           }
         }
        
$i++;
     } else {
        
$goon = false;
     }
   }

  
fclose($fdbf);
   return(
$dbfhdrarr);
}

$arr = get_dbf_header('/data/file.dbf');
print_r($arr);
?>
guillaume dot sueur at geosignal dot fr
07-Nov-2002 02:13
To retrieve the name of the fields.

$dbi = dbase_open($db_path, 0);    // opens the dbf file
$res = dbase_get_record_with_names($dbi, 1); // throw record 1 into associative array key=>value
$cles = array_keys($res);// retrieves all  the keys from previous array, which are field names.
Joerg Aldinger
16-Sep-2001 02:04
Note that dBase support on Windows is disabled by default.
Uncomment the following line in your php.ini file to enable it:

extension=php_dbase.dll

<timedbase_add_record>
 Last updated: Thu, 15 Jul 2004
show source | credits | sitemap | contact | advertising | mirror sites 
Copyright © 2001-2004 The PHP Group
All rights reserved.
This unofficial mirror is operated at: /
Last updated: Sun Nov 14 23:09:54 2004 Local time zone must be set--see zic manual page