#18913 [Bgs]: pg_pconnect opens a new connection even when and old one is available
| From: | jc at mega-bucks dot co dot jp | Date: | Thu, 15 Aug 2002 08:54:14 +0000 |
| Subject: | #18913 [Bgs]: pg_pconnect opens a new connection even when and old one is available | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-16892@lists.php.net to get a copy of this message | ||
ID: 18913
User updated by: jc@mega-bucks.co.jp
-Summary: pg_pconnect fails when trying to connect to a
different DB
Reported By: jc@mega-bucks.co.jp
Status: Bogus
Bug Type: PostgreSQL related
Operating System: Red Hat Linux 7.2
PHP Version: 4.2.2
New Comment:
My mistake, the max had been set to 1. Thanks for the friendly
reminder!
Previous Comments:
------------------------------------------------------------------------
[2002-08-15 04:37:20] sander@php.net
There's a ini-directive that limits the maximum number of persistant
connections. See phpinfo().
------------------------------------------------------------------------
[2002-08-15 03:30:50] jc@mega-bucks.co.jp
It seems that I cannot use pg_pconnect to connect to more than on
database at a time?
The following code fails with this error:
Warning: pg_pconnect() cannot create new link. Too many open links (1)
in /www/htdocs/jc/t2.php on line 26
Warning: pg_exec(): supplied argument is not a valid PostgreSQL link
resource in /www/htdocs/jc/t2.php on line 27
CONNECTION: could not execute query2 (select now())
<?php
$sql = "select now()";
//uncommenting one of the following lines will make the code work
$res1 = sql_query($sql);
$res2 = sql_query2($sql);
$dat = pg_fetch_object($res1); //or res2 as the case maybe
echo $dat->now;
function sql_query($sql) {
$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;
}
}
function sql_query2($sql) {
$conn = pg_pconnect("dbname=sessions user=postgres");
$res = pg_exec($conn, $sql);
if (!$res) {
echo "CONNECTION: could not execute query2 ($sql)<br>";
die;
}
else {
return $res;
}
}
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18913&edit=1