#47223 [Com]: Dbase corrupted - columns / date

From: Date: Tue, 27 Jan 2009 11:14:33 +0000
Subject: #47223 [Com]: Dbase corrupted - columns / date
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133239@lists.php.net to get a copy of this message
 ID:               47223
 Comment by:       Nicolas dot breuer at belcenter dot be
 Reported By:      Nicolas dot breuer at belcenter dot be
 Status:           Feedback
 Bug Type:         dBase related
 Operating System: Linux
 PHP Version:      5.2.8
 New Comment:

Yes problem was completely solved in CSV 5.2.9-dev

 I compared the two dbf_head.c files (5.2.8 > 5.2.9-dev)
 and i see few lines removed. I suppose it was the problem.
>>> REMOVED 

            case 'D':
                dbf->db_flen = 8;
                break;
            case 'L':
                dbf->db_flen = 1;
                break;
>>> REMOVED 


 Do you have an idea for the official release of 5.2.9 ?

 Thanks


Previous Comments:
------------------------------------------------------------------------

[2009-01-27 10:42:10] felipe@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/



------------------------------------------------------------------------

[2009-01-27 10:32:57] Nicolas dot breuer at belcenter dot be

Description:
------------
 Hello,

 This bug is present in the PHP source code since
 the release of PHP 5.2.4. We worked with 5.2.3 because
 we can put a newer release in prod. Today i tried to install
 the 5.2.8 and same problem so i publish now a bug report.

 -----

 I add one or more record to a DBase file.
 The header was already on the server 

 Problem is when i opened the file, the columns were truncated.

 Header of dbf file (empty of course)

 Array
(
    [0] => Array
        (
            [name] => NUM
            [type] => number
            [length] => 8
            [precision] => 0
            [format] => %8s
            [offset] => 1
        )

    [1] => Array
        (
            [name] => JNL
            [type] => character
            [length] => 10
            [precision] => 0
            [format] => %-10s
            [offset] => 9
        )

    [2] => Array
        (
            [name] => NUMBER
            [type] => number
            [length] => 10
            [precision] => 0
            [format] => %10s
            [offset] => 19
        )

    [3] => Array
        (
            [name] => DATE
            [type] => date
            [length] => 8
            [precision] => 0
            [format] => %8s
            [offset] => 29
        )

    [4] => Array
        (
            [name] => THIRDGROUP
            [type] => character
            [length] => 10
            [precision] => 0
            [format] => %-10s
            [offset] => 37
        )

    [5] => Array
        (
            [name] => ARTID
            [type] => character
            [length] => 20
            [precision] => 0
            [format] => %-20s
            [offset] => 47
        )

    [6] => Array
        (
            [name] => QTY
            [type] => number
            [length] => 10
            [precision] => 0
            [format] => %10s
            [offset] => 67
        )

    [7] => Array
        (
            [name] => UNITPRICE
            [type] => number
            [length] => 12
            [precision] => 2
            [format] => %12s
            [offset] => 77
        )

    [8] => Array
        (
            [name] => VATID
            [type] => character
            [length] => 10
            [precision] => 0
            [format] => %-10s
            [offset] => 89
        )

    [9] => Array
        (
            [name] => VATPC
            [type] => character
            [length] => 10
            [precision] => 0
            [format] => %-10s
            [offset] => 99
        )

    [10] => Array
        (
            [name] => DISCOUNT
            [type] => character
            [length] => 5
            [precision] => 0
            [format] => %-5s
            [offset] => 109
        )

    [11] => Array
        (
            [name] => ARTNAME
            [type] => character
            [length] => 60
            [precision] => 0
            [format] => %-60s
            [offset] => 114
        )

    [12] => Array
        (
            [name] => D_PMTAUTO
            [type] => character
            [length] => 1
            [precision] => 0
            [format] => %-1s
            [offset] => 174
        )

    [13] => Array
        (
            [name] => DATEPAY
            [type] => date
            [length] => 8
            [precision] => 0
            [format] => %8s
            [offset] => 175
        )

    [14] => Array
        (
            [name] => YOURREF
            [type] => character
            [length] => 10
            [precision] => 0
            [format] => %-10s
            [offset] => 183
        )



Reproduce code:
---------------
$dbname = "temp/test.dbf";
$dbh = dbase_open($dbname, 2)
or die("Error! Could not open dbase database file '$dbname'."); 

$reg=array("1","FAC","20090150","01/01/2009","TEST
INPUT","TEST ARTI
ID","1","50","0","0","0","Test input
char","","-","-"); 
dbase_add_record($dbh,$reg); 
$reg=array("1","FAC","20090150","01/01/2009","TEST
INPUT","TEST ARTI
ID","1","50","0","0","0","Test input
char","","-","-"); 
dbase_add_record($dbh,$reg); 




Expected result:
----------------
 Each value correctly in each column.

Actual result:
--------------

NUM	JNL	NUMBER	DATE	THIRDGROUP	ARTID	QTY	UNITPRICE	VATID	VATPC	DISCOUNT	ARTNAME	D_PMTAUTO	DATEPAY	YOURREF

1	FAC	20090150		01/01/20TE	ST INPUTTEST ARTI ID		1	      500	       
0		   0    Test input char			


1	FAC	20090150		01/01/20TE	ST INPUTTEST ARTI ID		1	      500	       
0		   0    Test input char		

 Date column was empty
 and the real date (truncated) was put on THIRDGROUP column.
 Thirdgroup value was put on ArtID column, etc.

 	


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47223&edit=1



Thread (4 messages)

« previous php.bugs (#133239) next »