ID:               37361
 Updated by:       [EMAIL PROTECTED]
 Reported By:      axel dot azerty at laposte dot net
-Status:           Open
+Status:           Bogus
 Bug Type:         PDO related
 Operating System: Fedora Core 5 - Linux 2.6.16
 PHP Version:      5.1.4
 New Comment:

This is expected behaviour.



Previous Comments:
------------------------------------------------------------------------

[2006-05-08 13:05:34] smlerman at gmail dot com

bindParam and bindValue treat the parameter as a string by default,
which means the value has special characters escaped and the entire
value quoted. Your code produces COALESCE(MAX('id_board'),0), which is
probably not what you want. You'll most likely need to place the field
name directly in the query instead of trying to bind it as if it were
normal data.

------------------------------------------------------------------------

[2006-05-08 07:01:03] axel dot azerty at laposte dot net

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 this bug report at http://bugs.php.net/?id=37361&edit=1

Reply via email to