The following pg_query()
calls trigger warnings:
// with an active and working default connection:
$res = pg_query("");
$res = pg_query(";");
$res = pg_query("// foo\n; ;\n /* bar */\n ; // baz");
The warning is "Warning: pg_query(): Query failed: in {script} on line {n}".
In all three cases, $res
is false
, signalling a failure, but pg_last_error()
is empty. The obvious cause is that the query string is empty (after removing comments and semicolons).
This is the only situation where I've ever seen a false
return value of pg_query()
without an error message in pg_last_error()
. I would like to log a message with the actual reason for the failure for debugging purposes. Can I rely on empty query strings being the only cause of this combination? Is there any other source of information about the failure, beside pg_last_error()
?