From: joshwaihi at gmail dot com
Operating system: Ubuntu
PHP version: 5.2.9
PHP Bug Type: PDO related
Bug description: PostgreSQL extension passes string param to int column when
passed NULL of FALS
Description:
------------
When FALSE or NULL is passed to int column, PostgreSQL 8.3 fails with the
following error: Invalid text representation: 7 ERROR: invalid input
syntax for integer: ""
It would seem the PDO postgreSQL driver is passing NULL and FALSE as a
string. This is not however, the case for the MySQL Driver.
Reproduce code:
---------------
try {
$dbh = new PDO('pgsql:dbname=test;', 'myUser');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->query('CREATE TABLE test (id int not null, name text not
null)');
$SQL = 'INSERT INTO test (id,name) VALUES (:id, :name)';
$query = $dbh->prepare($SQL);
$query->execute(array(':id' => 0, ':name' => 'This will work'));
$query->execute(array(':id' => FALSE, ':name' => 'This will not
work'));
} catch (Exception $e) {
print $e->getMessage();
}
$dbh->query('DROP TABLE test');
Expected result:
----------------
no output
Actual result:
--------------
SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input
syntax for integer: ""
--
Edit bug report at http://bugs.php.net/?id=48383&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48383&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48383&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48383&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48383&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48383&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48383&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48383&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48383&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48383&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48383&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48383&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48383&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48383&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48383&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48383&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48383&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48383&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48383&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48383&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48383&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48383&r=mysqlcfg