|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-06-09 19:02 UTC] andrewz at springsrescuemission dot org
Description: ------------ Using PHP's dbase system cannot understand some columns and yields garbage on a certain .dbf file (http://65.108.181.103/zip.dbf). The .dbf was tested successfully with several other programs (OpenOffice.org 1.1.4 and Shapefile Library C). According to file, .dbf is dbase 3 format: $ file zip.dbf zip.dbf: DBase 3 data file (586 records) To enable dbase support, I used the standard Trustix 2.2 source RPM and included "--enable-dbase". On a different system with PHP 4.3.10 and Linux 2.4.27 (Redhat 7.3), I verified the problem with dbase_get_record_with_names(). (The function dbase_get_header_info() was not available on this platform.) Reproduce code: --------------- $db = dbase_open("zip.dbf",0); print_r(dbase_get_header_info($db)); if ($db) { $record_numbers = dbase_numrecords($db); for ($i = 1; $i <= $record_numbers; $i++) { $row = dbase_get_record_with_names($db, $i); print_r($row); } } Expected result: ---------------- The dbase_header_info() does not understand some columns and includes garbage (e.g. length field). Then the dbase_get_record_with_names() has incorrect data. Here is output of Shapefile Library C's dbfdump -h on the same zip.dbf. This output is good. Field 0: Type=Double, Title=`AREA', Width=20, Decimals=5 Field 1: Type=Double, Title=`PERIMETER', Width=20, Decimals=5 Field 2: Type=Integer, Title=`ZT08_D00_', Width=11, Decimals=0 Field 3: Type=Integer, Title=`ZT08_D00_I', Width=11, Decimals=0 Field 4: Type=String, Title=`ZCTA', Width=5, Decimals=0 Field 5: Type=String, Title=`NAME', Width=90, Decimals=0 Field 6: Type=String, Title=`LSAD', Width=2, Decimals=0 Field 7: Type=String, Title=`LSAD_TRANS', Width=50, Decimals=0 AREA PERIMETER ZT08_D00_ ZT08_D00_I ZCTA NAME LSAD LSAD_TRANS 0.05115 1.30727 2 1 80428 80428 Z5 5-Digit ZCTA Actual result: -------------- SCRIPT OUTPUT Array ( [0] => Array ( [name] => AREA [type] => unknown [length] => 1300 [precision] => 0 [format] => ? "@ [offset] => 1 ) [1] => Array ( [name] => PERIMETER [type] => unknown [length] => 1300 [precision] => 0 [format] => ? "@ [offset] => 1301 ) [truncated] PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 08:00:01 2025 UTC |
Take for example the first entry in the header: [0] => Array ( [name] => AREA [type] => unknown [length] => 1300 [precision] => 0 [format] => ? "@ [offset] => 1 ) The type should be a double, the length 20, and the precision 5. Instead I get unknown, 1300, and 0.I can't reproduce it on 5.2.9-CVS: Array ( [0] => Array ( [name] => AREA [type] => float [length] => 20 [precision] => 0 [format] => %20s [offset] => 1 )