#37361 [NEW]: prepare statement alter the datatype of a parameter

From: Date: Mon, 08 May 2006 07:01:03 +0000
Subject: #37361 [NEW]: prepare statement alter the datatype of a parameter
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-96796@lists.php.net to get a copy of this message
From: axel dot azerty at laposte dot net Operating system: Fedora Core 5 - Linux 2.6.16 PHP version: 5.1.4 PHP Bug Type: PDO related Bug description: prepare statement alter the datatype of a parameter Description: ------------ The prepared statement in PDO seems to lost or to have its type altered. When typing a 'SELECT COALESCE(MAX(field),0) FROM table' under postgresql shell, no problem. When using this query as is in PHP (with PDO), no problem. When trying SELECT COALESCE(MAX(?),0) FROM table as a prepared statement, the execution fails. Replacing "MAX(?),0" by "MAX(?),'0'" solves the problem, but the returned value is a string, and not an integer. Reproduce code: --------------- $stmt = $dbh->prepare("SELECT COALESCE(MAX(?),0) FROM board"); $stmt->bindParam(1,$fld); $fld = "id_board"; if(!$stmt->execute()) print_r($stmt->errorInfo()); Expected result: ---------------- The expected result is "0" , in the case or the table is empty or the number of lines in the table. Actual result: -------------- The statement->errorInfo() returns : Array ( [0] => 42804 [1] => 7 [2] => ERREUR: Les COALESCE types text et integer ne peuvent pas correspondre ) In english : "the COALESCE types text and interger can't match". -- Edit bug report at http://bugs.php.net/?id=37361&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37361&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=37361&r=trysnapshot51 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37361&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37361&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37361&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37361&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37361&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37361&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37361&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37361&r=support Expected behavior: http://bugs.php.net/fix.php?id=37361&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37361&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37361&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37361&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37361&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37361&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37361&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37361&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37361&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37361&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37361&r=mysqlcfg

« previous php.bugs (#96796) next »