php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55239 dbase date field
Submitted: 2011-07-19 07:12 UTC Modified: 2011-07-19 18:21 UTC
From: m4rk dot gm4il at gmail dot com Assigned:
Status: Not a bug Package: dBase related
PHP Version: 5.3.6 OS: WINXP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: m4rk dot gm4il at gmail dot com
New email:
PHP Version: OS:

 

 [2011-07-19 07:12 UTC] 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', 
      'max@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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-19 18:21 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2011-07-19 18:21 UTC] felipe@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', 
      'max@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) "max@example.com                                                                                                                 "
  [4]=>
  int(1)
  ["deleted"]=>
  int(0)
}
 [2011-07-21 06:00 UTC] m4rk dot gm4il at gmail dot com
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC