|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-08-15 03:06 UTC] edink@php.net
[2002-08-15 03:09 UTC] jc at mega-bucks dot co dot jp
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 00:00:01 2025 UTC |
When I use pg_pconnect() I find that sometimes PHP creates a connection even if the is alrady a currently open one. This only happens *sometimes*. For example I reload my test code multiple times and I see no problem. However If I then load a new page, hit the back button and then re-load the test code I now see two open postgres connection where I only saw one before. # ps -auxw | grep idle root 3 0.0 0.0 0 0 ? SW 13:05 0:00 [kapm-idled] postgres 1409 0.0 0.4 6544 2208 ? S 15:53 0:00 postgres: postgres JC [local] idle postgres 1453 0.5 0.4 6544 2208 ? S 15:55 0:00 postgres: postgres JC [local] idle I use this code: <?php $sql = "select now()"; $res = sql_query($sql); $dat = pg_fetch_object($res); echo "$dat->now<br>"; function sql_query($sql) { //echo "$sql<br>"; $conn = pg_pconnect("dbname=JC user=postgres"); $res = pg_exec($conn, $sql); if (!$res) { echo "CONNECTION: could not execute query ($sql)<br>"; die; } else { return $res; } } ?> ~