dBASE was the first widely used database management system or DBMS for microcomputers, published by Ashton-Tate for CP/M, and later on the Apple II, Apple Macintosh, UNIX [1], VMS [2], and IBM PC under DOS where it became one of the best-selling software titles for a number of years. dBASE was never able to transition successfully to Microsoft Windows and was eventually displaced by newer products like Paradox, Clipper, FoxPro, and Microsoft Access. dBASE was sold to Borland in 1991, which sold the rights to the product line in 1999 to the newly-formed dBASE Inc.
Starting in the mid 1980s many other companies produced their own dialects or variations on the product and language. These included FoxPro (now Visual FoxPro), Arago, Force, Recital, dbFast, dbXL, Quicksilver, Clipper, Xbase++, FlagShip, and Harbour. Together these are informally referred to as xBase or XBase.
-------http://en.wikipedia.org/wiki/DBASE
Why shoud you learn to read dbf file? Because Esri shapefile stores the attribute information of geodata not in shapefile itself, but in other dbf file. Oh, I hate Esri, why need I to read so many different data formats??? I hope you can be the boss of the esri and change everything to make things easy.
But don't worry, there is always one hero will occor to save the earth. Who? dBase Functions in PHP! Wow~~~~~~
These functions in PHP allow you to access records stored in dBase-format (dbf) databases. But firstly, please remove the magic semicolon before dbase.dll in your php.ini file in order to use this function in PHP5. The oftenly used functions are these, you can find in PHP handbook.
// open in read-only mode
$db = dbase_open('capitals.dbf', 0);
if ($db) {
// read some data ..
dbase_close($db);
}
Use dbase_get_header_info to get the header info of a database and an indexed array with an entry for each column in the database. Each array element contains an associative array of column information, as described here:
The name of the column
The human-readable name for the dbase type of the column (i.e. date, boolean, etc.)
The number of bytes this column can hold
The number of digits of decimal precision for the column
A suggested printf() format specifier for the column
The byte offset of the column from the start of the row
function loadDBFHeader($DBFFileName)
{
$DBFFile = fopen($DBFFileName, 'r');
$result = array();
$buff32 = array();
$i = 1;
$inHeader = true;
while ($inHeader) {
if (!feof($DBFFile)) {
$buff32 = fread($DBFFile, 32);
if ($i > 1) {
if (substr($buff32, 0, 1) == chr(13)) {
$inHeader = 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($result, array($fieldName, $fieldType, $fieldLen, $fieldDec));
}
}
$i++;
} else {
$inHeader = false;
}
}
fclose($DBFFile);
return($result);
}
For those users they could not use dbase function in their remote server host, sorry I have not found any solutions to read the dbase record. Maybe someone could help me for that, because I am the pathetic one among them T_T
Anyway, the stupid source code is available here: loadDbf.rar
Ref:
http://www.clicketyclick.dk/databases/xbase/format/dbf.html#DBF_STRUCT
http://en.wikipedia.org/wiki/DBASE
PHP5 handbook
Comments
Post new comment