From:             kenaniah at gmail dot com
Operating system: *
PHP version:      5.2.9
PHP Bug Type:     PDO related
Bug description:  PDO parameter binding is in clear violation of the ISO 9075 
standard

Description:
------------
Referencing ISO 9075, PDO does not properly bind boolean parameters when
the parameter type has not been made known to PDO.

According to the standard, booleans represent a truth, false, or unknown
value. According to the SQL language definition (feel free to reference
SQL-92), the SQL equivalents for a boolean value are TRUE, FALSE, and NULL
respectively.

The PDO core should automatically convert boolean values to their proper
SQL counterparts, and it should be the role of the client driver to deal
with these values if the database platform in question does not support the
ISO standard. 

Rather than listing workarounds, we ask that the PDO core be brought into
compliance with the SQL standards, and that individual database drivers be
modified to handle the cases in which their underlying database is not
standards compliant. 

Reproduce code:
---------------
$res = $db->prepare('SELECT id FROM table WHERE mybool = ?');
$res->execute(array(false));

Expected result:
----------------
SQL statement sent to server:

SELECT id FROM table WHERE mybool = FALSE

(unless modified by DB driver due to a lack of standards compliance on the
part of the DB)

Actual result:
--------------
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input
syntax for type boolean: ""' 

^^for Postgres driver (Postgres is an standard compliant DB as far as
booleans are concerned)

-- 
Edit bug report at http://bugs.php.net/?id=47615&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47615&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47615&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47615&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47615&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47615&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47615&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47615&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47615&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47615&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47615&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47615&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47615&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47615&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47615&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47615&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47615&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47615&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47615&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47615&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47615&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47615&r=mysqlcfg

Reply via email to