ID: 818 Updated by: jimw Reported By: [EMAIL PROTECTED] Old-Status: Analyzed Status: Closed Bug Type: Feature/Change Request Assigned To: zeev Comments: this was a duplicate of 729. Previous Comments: --------------------------------------------------------------------------- [1998-10-05 10:36:40] [EMAIL PROTECTED] pg_Connect() doesn't always return a unique connection identifier. This is a problem for code that uses nested connections, or code that "hides" connections by using objects. One work-around is to not explicitly call pg_Close() from the nested connection. The other is to do away with this feature - because it smells a lot like pg_pConnect(). Here's a small piece of code: <? $HOST = "localhost"; $PORT = "5432"; $DATABASE = "template1"; function Nested() { global $HOST, $PORT, $DATABASE; $conn = pg_Connect($HOST, $PORT, "", "", $DATABASE); if ($conn) { echo "Nested id: $connn"; pg_Close($conn); } } function SomeFunc() { global $HOST, $PORT, $DATABASE; $conn = pg_Connect($HOST, $PORT, "", "", $DATABASE); if ($conn) { echo "First id: $connn"; Nested(); pg_Close($conn); } } SomeFunc(); ?> Running this code yields: First id: 1 Nested id: 1 <br> <b>Warning</b>: 1 is not a PostgreSQL link index in <b>foo.php3</b> on line <b>23</b><br> The expected output is: First id: 1 Nested id: 2 The cause is the lookup performed inside pg_Connect(). Whenever a connection is established, it's stored in a hash table. Then, when a new connection is requested, the connection parameters are looked up in the hash table, and if a match is found, an existing connection id is returned. You can see this behaviour by changing one of the above pg_Connect() lines to: $conn = pg_Connect("127.0.0.1", $PORT, "", "", $DATABASE); This will cause the lookup to fail because localhost looks different from 127.0.0.1 in the lookup. I have a feeling this may be something leftover from before pg_pConnect()... -Brian Schaffner- --------------------------------------------------------------------------- ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=818&edit=2 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]