#34911 [Opn->Bgs]: php_dbase.dll : dbase_replace_record : tricks to work

From: Date: Fri, 21 Oct 2005 21:13:35 +0000
Subject: #34911 [Opn->Bgs]: php_dbase.dll : dbase_replace_record : tricks to work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-86905@lists.php.net to get a copy of this message
ID: 34911 Updated by: tony2001@php.net Reported By: allan dot s dot oliveira at gmail dot com -Status: Open +Status: Bogus Bug Type: dBase related Operating System: Windows NT WXP 5.1 build 2600 PHP Version: 5.0.5 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php dbase_get_record*() funcs return a row and add "deleted" field to indicate if this row were marked for deletion or not. You can see a note about it in dbase_replace_record() reference: "Note: If you're using dbase_get_record() return value for this parameter, remember to reset the key named deleted." Also, dbase_replace/add_record() work only with indexed arrays and this is documented too. Previous Comments: ------------------------------------------------------------------------ [2005-10-18 19:52:39] allan dot s dot oliveira at gmail dot com Description: ------------ the last bug report was 2001... but, here it goes. if you get the record and simply try to replace it using the loaded array, the number of arguments is invalid. Reproduce code: --------------- <?php $dbname = "./tmp/test.dbf"; // dbf name $def = array( array("date", "D"), array("name", "C", 50), array("age", "N", 3, 0), array("email", "C", 128), array("ismember", "L") ); // structure dbase_create($dbname, $def) // creating $db=dbase_open($dbname,2) // open to insert $reg=array("20030912","My Name","33","example@example.com",False); // define record dbase_add_record($db,$reg) // insert record dbase_close($db); // close $db=dbase_open($dbname,2) // open to replace $row = dbase_get_record_with_names($db, 1); // gets actual row $row['email'] = "newmail@newmail.com"; // Update the date field with the current timestamp dbase_replace_record($db,$row,1); // replace // above instruction causes an error : incorrect number of arguments $reg = array( $row['date'] , $row['name'] , $row['age'] , $row['email'] , $row['ismember'] ); // redefine record without 'deleted' column dbase_replace_record($db,$reg,1); // Replace the record : OK // This Replace goes OK dbase_close($db); echo "Done"; ?> Expected result: ---------------- this should work properly, without any tricks : $row = dbase_get_record_with_names($db, 1) $row['email'] = "newmail@newmail.com"; dbase_replace_record($db,$row,1); Actual result: -------------- I recently start to work with some dbase files, and following the examples, this error should not appear. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34911&edit=1

« previous php.bugs (#86905) next »