Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.3

Bug #10211 MySQL v5.x 'bit' fields not recognized
Submitted: 2007-02-27 19:31 UTC
From: mbuchmann at shaw dot ca Assigned: aharvey
Status: Closed Package: DB (version 1.7.9)
PHP Version: 5.1.6 OS: RHEL3
Roadmaps: 1.7.10    
Subscription  


 [2007-02-27 19:31 UTC] mbuchmann at shaw dot ca (Marc)
Description: ------------ MySQL introduced true 'bit' fields in the 5.x series, superceding the tinyint(1) fields they'd been using to fake them in previous versions. DB 1.7.9 (haven't tested previous versions, but they're very likely to be also affected) report these bit fields as type "unknown" and default them to a 'true' value for boolean true/false, no matter what's actually stored in the field. NULL values come through as blank, as expected. Workaround is the modify the query to CAST() the bit fields to an unsigned integer. Test script: --------------- MySQL: CREATE TABLE bugsample ( bitfield BIT default FALSE ); INSERT INTO bugsample (bitfield) VALUES (true), (false), (NULL); // create 3 records with the extended insert syntax PHP: $query = <<<EOF SELECT bitfield AS buggy, CAST(bitfield AS unsigned integer) AS fixed FROM bugsample; EOF; $sth = $dbh->query($query); print_r($dbh->tableInfo($sth)); while(list($buggy, $fixed) = $sth->fetchRow()) { $x = ($buggy) ? 'true' : 'false'; print("buggy: $buggy/$x fixed: $fixed\n"); } Expected result: ---------------- Array ( [0] => Array ( [table] => bugsample [name] => buggy [type] => bit <----!!!!!! [len] => 1 [flags] => ) [1] => Array ( [table] => [name] => fixed [type] => int [len] => 1 [flags] => unsigned binary ) ) buggy: /true fixed: 1 buggy: �/false fixed: 0 <---!!!!!!! buggy: /false fixed: Actual result: -------------- Array ( [0] => Array ( [table] => bugsample [name] => buggy [type] => unknown [len] => 1 [flags] => ) [1] => Array ( [table] => [name] => fixed [type] => int [len] => 1 [flags] => unsigned binary ) ) buggy: /true fixed: 1 buggy: �/true fixed: 0 <---!!!!!! buggy: /false fixed:

Comments

 [2007-03-20 09:24 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2020-05-22 16:48 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!