PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<timedbase_add_record>
view the version of this page
Last updated: Sun, 02 May 2004

XVIII. Funzioni dBase

Queste funzioni consentono di accedere ai records memorizzati in dBase-format (dbf) database. Per poter usare queste funzioni, si deve prima compilare il PHP con l'opzione --enable-dbase option.

Non è previsto il supporto per indici o campi memo. Manca anche il supporto per il locking. E' probabile che due processi concorrenti da parte del webserver sugli stessi file dBase, finiscano con il rovinare il Database.

I files dBase sono semplici files sequenziali o records a lunghezza fissa. I record sono appesi alla fine del file e quelli cancellati sono conservati fino alla chiamata della funzione dbase_pack().

Vi raccomandiamo di non usare i files dBase come database di lavoro. Scegliete piuttosto qualsiasi reale SQL server; MySQL o Postgres sono scelte comuni con PHP. Il supporto dBase è presente per permettervi di importare ed esportare dati da e verso il vostro web database, perchè il formato del file è comunemente ben interpretato dai fogli elettronici e dagli organizers di Windows.

Sommario
dbase_add_record -- Aggiunge un record ad un database dBase
dbase_close -- Chiude un database dBase
dbase_create -- Crea un database dBase
dbase_delete_record -- Cancella un record da un database dBase
dbase_get_header_info -- Get the header info of a dBase database
dbase_get_record_with_names --  Estrae un record da un database dBase come un array associativo
dbase_get_record -- Estrae un record da un database dBase
dbase_numfields --  Restituisce il numero di campi in un database dBase.
dbase_numrecords --  Restituisce il numero di records in un database dBase.
dbase_open -- Apre un database dBase
dbase_pack -- Stabilizza un database dBase
dbase_replace_record -- Sostituisce un record in un database dBase


add a note add a note User Contributed Notes
Funzioni dBase
Hadi Rusiah / deegos at yahoo dot com
08-May-2004 04: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 12: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 01: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: Sun, 02 May 2004
show source | credits | sitemap | contact | advertising | mirror sites 
Copyright © 2001-2004 The PHP Group
All rights reserved.
This mirror generously provided by: Italia OnLine S.p.a.
Last updated: Fri May 21 04:11:23 2004 CEST