From:             mattias dot geniar at gmail dot com
Operating system: CentOS 5.2
PHP version:      5.2.6
PHP Bug Type:     dBase related
Bug description:  Corrupt DBF When Using DATE

Description:
------------
Creating a dBase file with a DATE-field type, will corrupt the database.
Work-around as for now is to use a CHAR-type and convert it later
manually.

This bug is similar to #42261, which dates back to August 2007.

Reproduce code:
---------------
<?php
        // database "definition"
        $def = array(
          array("date",     "D"),
          array("name",     "C",  50),
          array("email",    "C", 128),
          array("ismember", "L")
        );

        // creation
        if (!dbase_create('test.dbf', $def)) {
          echo "Error, can't create the database\n";
        }

        // open in read-write mode
        $db = dbase_open('test.dbf', 2);

        if ($db) {
                for ($i = 0; $i < 5; $i++) {
                        dbase_add_record($db, array(
                              date('Ymd'),
                              'Name #'. $i,
                              'Email #'. $i,
                              'T'));
                }
          dbase_close($db);
        }
?>


Expected result:
----------------
A simple database with 5 lines, where DATE, Name & Email are entered
correctly.

Actual result:
--------------
The code above will create file called "test.dbf", which is corrupted when
opening it with any normal DBF-viewer (CDBF, DBF Manager, ...). If the
DATE-field is replaced with a CHAR-field, all works fine. Date-format is
taken from the PHP.NET website and confirmed by the dBase-format.

-- 
Edit bug report at http://bugs.php.net/?id=46282&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=46282&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=46282&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=46282&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=46282&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=46282&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=46282&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=46282&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=46282&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=46282&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=46282&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=46282&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=46282&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=46282&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=46282&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=46282&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=46282&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=46282&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=46282&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=46282&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=46282&r=mysqlcfg

Reply via email to