ID: 44791 Updated by: [email protected] Reported By: php at benjaminschulz dot com -Status: Analyzed +Status: Bogus Bug Type: Feature/Change Request Operating System: osx PHP Version: 5.3CVS-2008-04-21 (CVS) New Comment:
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 I think the behaviour is exactly what I would expect. PostrgeSQL booleans are "t" and "f". Recent PgSQL versions also accept 1 and 0 as input for booleans, but not the empty string, which is what PHP outputs for a bool(false). The pgsql PHP extension wasn't written with portability in mind, so it expects users to have knowledge of how PostgreSQL works. In this specific case, prepare/execute don't do any type of magic and just cast the parameters to string. Your example should in fact look like: $result = pg_execute($dbconn, "my_query", array('t')); $result = pg_execute($dbconn, "my_query", array('f')); I've been pointed to this bug by Pierre and discussed with him about it. Previous Comments: ------------------------------------------------------------------------ [2008-04-21 09:35:55] php at benjaminschulz dot com This applies to pg_send_execute, too. ------------------------------------------------------------------------ [2008-04-21 09:32:58] [email protected] The problem is due to the way the casting is done internally: SEPARATE_ZVAL(tmp); convert_to_string_ex(tmp); if (Z_TYPE_PP(tmp) != IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter"); _php_pgsql_free_params(params, num_params); RETURN_FALSE; } It could be improved by testing the variable type prior to convert. However I'm not sure if it is desired or if it has some bad side effects like BC breaks. ------------------------------------------------------------------------ [2008-04-21 09:14:38] php at benjaminschulz dot com Description: ------------ Binding a boolean "false" to a statement doesn't work. Reproduce code: --------------- $result = pg_prepare($dbconn, "my_query", 'SELECT * FROM test WHERE boolfield = $1'); $result = pg_execute($dbconn, "my_query", array(true)); // works $result = pg_execute($dbconn, "my_query", array(false)); // triggers an error Expected result: ---------------- No error ;) Actual result: -------------- Warning: pg_execute(): Query failed: ERROR: invalid input syntax for type boolean: "" in ... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44791&edit=1
