pg_last_error() doesn't return connection errors

Frank Naude <[email protected]> Thu, 26 Aug 2010 13:44:44 +0200
Newsgroups gmane.comp.db.postgresql.php
Message-ID <[email protected]>
Hi,

I can successfully connect to PostgreSQL (pgsql extension). However,
when I make a deliberate mistake, I'm unable to capture the connection
error with pg_last_error() as one would with the *_last_error()
functions of other database extensions.

Here is an example:

<?php
$c = pg_connect('host=127.0.0.1 user=postgres password=xxx
dbname=yyy') or var_dump( pg_last_error() );
?>

The following output (with warnings) is returned:

Warning: pg_connect() [function.pg-connect]: Unable to connect to
PostgreSQL server: FATAL: password authentication failed for user
"postgres" in ..
Warning: pg_last_error() [function.pg-last-error]: No PostgreSQL link
opened yet in ...
bool(false)

One would expect pg_last_error() to return "password authentication
failed" instead of FALSE!

Best regards.

Frank

-- 
Sent via pgsql-php mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php