Edit report at https://bugs.php.net/bug.php?id=55239&edit=1

 ID:                 55239
 Comment by:         m4rk dot gm4il at gmail dot com
 Reported by:        m4rk dot gm4il at gmail dot com
 Summary:            dbase date field
 Status:             Bogus
 Type:               Bug
 Package:            dBase related
 Operating System:   WINXP
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

Hi,

Thanks for your response.

When I execute the same var_dump command,
I can also see the same result as yours on the browser.

But when I actually open the database on excel or foxpro, I
can see the structure. the "Date" and "Logical" 
data fields have '0' length.

I also tried to create a sample database using foxpro
with data on it and the structure has correct field length 
with "Date" and "Logical" types.  

Then using that database created from foxpro and using the 
same given code but I just removed the database creation part,  
I opened the database using dbase_open() and inserted the record
using dbase_add_record(), it also resulted from 0 FIELD LENGTH
for Date and Logical types.


Previous Comments:
------------------------------------------------------------------------
[2011-07-19 18:21:15] fel...@php.net

Hi, report dbase bugs on http://pecl.php.net/bugs/report.php?package=dbase

Anyway, I've tested and it works fine:

<?php

date_default_timezone_set('UTC');

$def = array(
  array("date",     "D"),
  array("name",     "C",  50),
  array("age",      "N",   3, 0),
  array("email",    "C", 128),
  array("ismember", "L")
);

dbase_create ('/tmp/test.dbf', $def);
$db = dbase_open('/tmp/test.dbf', 2);

dbase_add_record($db, array(
      date('Ymd'), 
      'Maxim Topolov', 
      '23', 
      'm...@example.com',
      'T'));   

var_dump(dbase_get_record($db, 1));
dbase_close($db);


array(6) {
  [0]=>
  string(8) "20110719"
  [1]=>
  string(50) "Maxim Topolov                                     "
  [2]=>
  int(23)
  [3]=>
  string(128) "m...@example.com                                                 
                                                                "
  [4]=>
  int(1)
  ["deleted"]=>
  int(0)
}

------------------------------------------------------------------------
[2011-07-19 07:12:25] m4rk dot gm4il at gmail dot com

Description:
------------
---
>From manual page: http://www.php.net/function.dbase-add-record%23Examples
and http://www.php.net/manual/en/function.dbase-create.php
---

<?php

// database "definition"
$def = array(
  array("date",     "D"),
  array("name",     "C",  50),
  array("age",      "N",   3, 0),
  array("email",    "C", 128),
  array("ismember", "L")
);

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


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

if ($db) {
  dbase_add_record($db, array(
      date('Ymd'), 
      'Maxim Topolov', 
      '23', 
      'm...@example.com',
      'T'));   
  dbase_close($db);
}

?>

Expected result:
----------------
the data on date, name, age, email, ismember
should all be saved on dbf.


Actual result:
--------------
upon saving the database, the date field and ismember field have 0 length.



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



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

Reply via email to