|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-09-24 15:59 UTC] larry at diabloresults dot com
Description:
------------
I have created a dbase table with the following schema:
$schema = array (
array('ACCOUNTNO','c',20),
array('COMPANY','c',40),
array('CONTACT','c',40),
array('LASTNAME','c',15),
array('TITLE','c',30),
array('PHONE1','c',25),
array('PHONE2','c',25),
array('PHONE3','c',25),
array('FAX','c',25),
array('EXT1','c',6),
array('EXT2','c',6),
array('EXT3','c',6),
array('EXT4','c',6),
array('ADDRESS1','c',40),
array('ADDRESS2','c',40),
array('CITY','c',26),
array('STATE','c',3),
array('ZIP','c',10),
array('KEY5','c',20),
array('UCRDEAEXP1','D'),
array('UCREDSSN','c',11),
array('UCREDFEDID','c',11),
array('URECACLSEX','D'),
array('URECATLSEX','D'),
array('UCRTLEXP1','D'),
array('UCRTST1','c',2),
array('URECPALSEX','D')
);
I am trying to add the following record:
Array
(
[0] => 1234FooBar
[1] =>
[2] => Paul W. Geiger
[3] => Geiger
[4] => Dr.
[5] => (618)271-7061 Home
[6] =>
[7] => (618)795-0629 cell
[8] =>
[9] => Home
[10] => Cell
[11] => Work
[12] =>
[13] => 2517 N. 38th Street;
[14] =>
[15] => Fairmont City
[16] => IL
[17] => 62201
[18] =>
[19] => 20110930
[20] => ssn
[21] =>
[22] => 20110831
[23] => 20090630
[24] =>
[25] => IL
[26] => 00000000
)
Using my friendly dbf viewer, I get the following:
1234FooBar, ,Paul W. Geiger ,Geiger ,Dr. ,(618)271-7061 Home , ,(618)795-0629 cell , ,Home ,Cell ,Work , ,2517 N. 38th Street; , ,Fairmont City ,IL ,62201 , ,09/30/2011,20110930ssn, , / / , / / , / / , , /20/
Note the first date field goes in correctly but the following fields are corrupted. If I change all the date fields except the last one, the data in inserted 'correctly'. This is not a viable solution as this dbf table is used to transfer data to a legacy system.
I have looked at hex dumps of the header and the Field Displacement in the record and the Field length are not specified/
Reproduce code:
---------------
<?php
$schema = array (
array('ACCOUNTNO','c',20),
array('UCRDEAEXP1','D'),
array('UCRTST1','c',2),
array('URECPALSEX','D')
);
$dbf = dbase_create('TEST.DBF', $schema);
$data = array('Text Data', '20110911', 'ST', '20111111');
dbase_add_record($dbf, $data);
dbase_close($dbf);
?>
Expected result:
----------------
From the dbf viewer:
Text Data,09/11/2011,ST,11/11/2011
Actual result:
--------------
From the dbf viewer:
Text Data,09/11/2011,20,11/ST/1109
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 23:00:01 2025 UTC |
This may be a windows issue. - it appears to work fine on unix, and I do not have any windows machines to test on. <?php dl('dbase.so'); if (file_exists('/tmp/TEST.DBF')) { unlink('/tmp/TEST.DBF'); } $schema = array ( array('ACCOUNTNO','c',20), array('UCRDEAEXP1','D'), array('UCRTST1','c',2), array('URECPALSEX','D') ); $dbf = dbase_create('/tmp/TEST.DBF', $schema); $data = array('Text Data', '20110911', 'ST', '20111111'); dbase_add_record($dbf, $data); dbase_close($dbf); // let's look at it.. passthru('/usr/bin/dbview /tmp/TEST.DBF'); ------ Outputs: Accountno : Text Data Ucrdeaexp1 : 20110911 Ucrtst1 : ST Urecpalsex : 20111111