|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-04-26 15:30 UTC] sesebs at gmail dot com
Description:
------------
In order to verify my connection to PostgreSql, I use PG_CONNECTION_STATUS(). When I try to check my connection, I have a warning who said : "pg_connection_status(): 103 is not a valid PostgreSQL link resource".
PG_CONNECTION_STATUS() should return just PGSQL_CONNECTION_BAD if the connection is not a valid PostgreSQL link ressource. Why there is a warning who appears ?
Test script:
---------------
$state = pg_connection_status($conn);
if ($state === PGSQL_CONNECTION_OK) {
return true;
}
Actual result:
--------------
pg_connection_status(): 103 is not a valid PostgreSQL link resource
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 15:00:01 2025 UTC |
You are right. I have just tested it in a postgresql server right now and I don't get a warning from pg_connection_status(). Still, I am using version 5.3.3 of PHP. But a strange behavior, is that my pg_connection_status returns boolean FALSE if resource is not valid, which is different from 0 of PGSQL_CONNECTION_BAD: $valid_resource = pg_connect('host=~ valid string here'); $invalid_resource = null; var_dump( pg_connection_status( $valid_resource ) ); // int(0) as expected var_dump( pg_connection_status( $invalid_resource ) ); // bool(false) var_dump( PGSQL_CONNECTION_BAD ); // int(1) different from bool(false) var_dump( PGSQL_CONNECTION_OK ); // int(0) as expected