<?php
class MyClassA
{
function __construct($connection_string)
{
$this->conn =
pg_pconnect($connection_string)
or die('错误的 CONN_STRING');
}
}
echo '<br>pgsql.allow_persistent: ' . ini_get('pgsql.allow_persistent');
echo '<br>pgsql.max_persistent: ' . ini_get('pgsql.max_persistent');
echo '<br>pgsql.max_links: ' . ini_get('pgsql.max_links');
echo '<br><br>';
$connection_string =
'host=localhost port=5432' .
' dbname=test user=test password=test';
$objArr = Array();
for ($i = 0; $i < 10; $i++)
{
$objArr[] = new MyClassA($connection_string);
}
foreach($objArr as $id => $object)
{
printf(
'%s: Object %s: using db %s<br>',
get_class($object), $id, $object->conn
);
}
?>