ID:               33876
 Updated by:       [EMAIL PROTECTED]
 Reported By:      php at sagi dot org
-Status:           Open
+Status:           Feedback
 Bug Type:         PDO related
 Operating System: Linux
 PHP Version:      5CVS-2005-07-27 (dev)
 New Comment:

Try this as a workaround for now:

$res = $db->prepare('SELECT ...', array(
   PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => true
  ));

You can blame the pretty poor native prepared statement API in pgsql
for this one; it just doesn't tell PDO anything about the parameter
types so it can't make an informed decision about how to treat the
parameters.



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

[2005-07-27 15:56:26] php at sagi dot org

I know how string casting works, but this is not a string.

PDO knows, for example, how to convert PHP NULL to SQL NULL and not
string('') (like string casting does). Why can't it cast bool values to
an integer instead?

This behavior is bad. PDO knows how to cast the value to real php bool
when selecting, but cannot cast it back when inserting/updating, which
means a simple attempt to re-insert a row that has just been selected,
using the same object, fails.

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

[2005-07-27 15:16:02] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is expected behaviour, when cast to a string bool false is
converted to "" while bool true converted to "1". 

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

[2005-07-27 00:14:50] php at sagi dot org

Description:
------------
Running latest php5 snapshot (php5-200507261230), PDO connected to
pgsql 8.0 server.

I'm trying to run a query similar to this:
$res = $db->prepare('SELECT id FROM table WHERE mybool = ?');
$res->execute(array(false));

PDO throws this exception: 'SQLSTATE[22P02]: Invalid text
representation: 7 ERROR:  invalid input syntax for type boolean: ""'

The query that has been executed, according to the server log, is:
"SELECT id FROM table WHERE mybool = ''"

Which is obviously not right. When trying to run the same query with
bool(true) parameter, PDO correctly quotes it as '1'.



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


-- 
Edit this bug report at http://bugs.php.net/?id=33876&edit=1

Reply via email to