ID: 13865 Updated by: sniper Reported By: [EMAIL PROTECTED] Status: Closed Bug Type: dBase related Operating System: Win32 PHP Version: 4.0.6 New Comment:
www.php4win.com has the win32 snapshots. Previous Comments: ------------------------------------------------------------------------ [2001-10-30 18:51:05] [EMAIL PROTECTED] This is fixed in CVS. Try a snapshot from http://snaps.php.net/ ------------------------------------------------------------------------ [2001-10-30 16:19:37] [EMAIL PROTECTED] I looked over the code in dbase.c and saw that boolean values are not handled very well. I made some code changes and got the following output. 0 NAME is Clinton and MALE is boolean of value 1 1 NAME is Debbie and MALE is boolean of value 2 NAME is Benjamin and MALE is boolean of value 1 3 NAME is Anna and MALE is boolean of value Here is a suggestion for a code change to dbase.c in the functions: PHP_FUNCTION(dbase_get_record) { PHP_FUNCTION(dbase_get_record_with_names) { CHANGE ----------------------------------------------- case 'N': /* FALLS THROUGH */ case 'L': /* FALLS THROUGH */ TO ----------------------------------------------- case 'L': /* 30 Oct 2001 [EMAIL PROTECTED] */ { int nValue = toupper(*get_field_val(data, cur_f, fnp)); if (nValue == 'T' || nValue == 'F' || nValue == 'Y' || nValue == 'N') { /* make sure this is a boolean and not a NULL */ add_assoc_bool(return_value,cur_f->db_fname, (nValue == 'T' || nValue =='Y')); } else { add_assoc_null(return_value,cur_f->db_fname); } break; } case 'N': /* FALLS THROUGH */ ------------------------------------------------------------------------ [2001-10-29 15:40:06] [EMAIL PROTECTED] dbase_get_record_with_names is not returning the correct values when I am checking a boolean field. Here is the test I used. function CreateDummy() { $fields = array( array("NAME", "C", 32), array("MALE", "L")); $db = dbase_create("dummy.dbf", $fields); dbase_add_record($db, array("Clinton", "T")); dbase_add_record($db, array("Debbie", "F")); dbase_add_record($db, array("Benjamin", "T")); dbase_add_record($db, array("Anna", "F")); dbase_close($db); } function WorkDummy() { CreateDummy(); $db = dbase_open("dummy.dbf", 0); if ($db == FALSE) { echo "<h2>Unable to open the dbase.</h2>"; exit; } for ($i = 0; $i < 4; $i++) { $dummy = dbase_get_record_with_names($db, $i+1); echo "$i NAME is ". $dummy['NAME'] ." and MALE is ". gettype($dummy['MALE']) . " of value ".$dummy['MALE']. "<br>\n"; } } I get the following output. 0 NAME is Clinton and MALE is integer of value 0 1 NAME is Debbie and MALE is integer of value 0 2 NAME is Benjamin and MALE is integer of value 0 3 NAME is Anna and MALE is integer of value 0 ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=13865&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]