ID: 16569
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Open
+Status: Bogus
Bug Type: PostgreSQL related
Operating System: RedHat 7.0
PHP Version: 4.1.1
New Comment:
This is not a bug. If you look at the resource ids returned from the
pg_connect() calls you would see that the second call actually returns
the same resource id as the first. That is, $conn1 = $conn2, so
naturally closing $conn2 will also close $conn1. Basically PHP keeps
track of open connections and if you try to open a second connection
with the exact same credentials it will reuse the existing one.
Previous Comments:
------------------------------------------------------------------------
[2002-04-12 12:30:09] [EMAIL PROTECTED]
/* TWO CONNECTIONS TO SAME SERVER, SAME DATABASE */
$conn1=pg_Connect("host=172.15.15.1 user=me dbname=mydb");
$conn2=pg_Connect("host=172.15.15.1 user=me dbname=mydb");
/* QUERIES HERE OK ON EITHER CONNECTION */
$result=pg_exec($conn1, "select stuff from table");
$result=pg_exec($conn2, "select stuff from table");
/* CLOSE conn2, conn1 SHOULD STILL BE OPEN */
$conn2=pg_close($conn2);
$result=pg_exec($conn1, "select stuff from table");
// ERROR! $conn1 seems to have been closed!
// MAYBE YOU ASK WHY WE DO TWO CONNS TO SAME db?
// NORMALLY, THEY ARE TWO DIFFERENT db's, MAIN and
// BACKUP. IN A failover SITUATION, BACKUP DB IS
// DOING BOTH JOBS, SO BOTH CONNS TO SAME MACHINE
// OUR PROBLEM FIXED WITH CONDITIONAL CODE: EG: IF
// MAIN AND BACKUP DBS ARE SAME, DON'T MAKE SECOND
// CONNECTION, BUT .... THOUGHT YOU SHOULD KNOW
// ABOUT THIS.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16569&edit=1