ID:               46282
 Updated by:       [EMAIL PROTECTED]
 Reported By:      mattias dot geniar at gmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         dBase related
 Operating System: CentOS 5.2
 PHP Version:      5.2.6
 New Comment:

Please try using this CVS snapshot:

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

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




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

[2008-10-12 14:03:50] mattias dot geniar at gmail dot com

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 this bug report at http://bugs.php.net/?id=46282&edit=1

Reply via email to