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

Bug #8668 Inconsistent return values for boolean types
Submitted: 2006-09-08 21:45 UTC
From: jose at infoviaweb dot com Assigned:
Status: Bogus Package: MDB2 (version 2.2.2)
PHP Version: Irrelevant OS: irrelevant
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 39 - 37 = ?

 
 [2006-09-08 21:45 UTC] jose at infoviaweb dot com (José de Paula Rodrigues)
Description: ------------ I'm using both MDB2_Driver_mysql and MDB2_Driver_pgsql. When I query for a boolean field, the MDB2_Driver_pgsql returns 't' or 'f', but the MDB2_Driver_mysql returns 1 or 0. I haven't tested other drivers, but I suspect they show this same inconsistency. They should return either true, false or null, or 't', 'f', or 'null'; anything, as long as all drivers are consistent. Versions used: PHP 5.1.5 (from FreeBSD ports) MySQL 5.1.11 (beta) (from FreeBSD ports) PostgreSQL 8.1.4 (from FreeBSD ports) MDB2 2.2.2 (from channel PEAR.PHP.NET) MDB2_Driver_mysql 1.2.2 (from channel PEAR.PHP.NET) MDB2_Driver_pgsql 1.2.2 (from channel PEAR.PHP.NE) Test script: --------------- <?php require_once "MDB2.php"; $dsn = "mysql://someuser:somepassword@somehost/somedb"; //$dsn = "pgsql://someuser:somepassword@somehost/somedb"; /* the table tbl below is defined as: CREATE TABLE tbl ( value1 bool, value2 bool ); INSERT INTO tbl (value1, value2) VALUES(true, false); */ $db =& MDB2::connect($dsn); $sql = "SELECT * FROM tbl"; $rs = $db->query($sql); // error check ommited while($row = $rs->fetchRow()) { echo "value1: " . $row[0]; // pgsql shows 't', mysql shows '1' echo "\nvalue2: " . $row[1]; // pgsql shows 'f', mysql shows '0' } ?> Expected result: ---------------- value 1: true value 2: false or value 1: t value 2: f consistently across all databases Actual result: -------------- mysql returns value 1: 1 value 2: 0 pgsql returns value 1: t value 2: f

Comments

 [2006-09-09 17:23 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!
 [2011-01-21 20:59 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!
 [2011-01-21 20:59 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!