[phplib] PHPLib and PostgreSQL (backend still open) From: Konstantin Borchert (borchert <email protected>)
Date: 04/25/01

Hi,

i have a serious problem with phplib 7.2c and postgresql 7.0.3 on a
redhat 6.2 linux server.
When i execute a query to the db-server, a connection to postgresql will
start and i get the
result what i want. After the query is finished, the backend is still
open and reserve more than 12MB for
the process over a long time. When i get many client connections the RAM
is full after a while. and the server
is lame.

e.g. a phplib script

$db = new dbconnection;
$db->query("SELECT id FROM xyz;");

while ($db->next_record()) {
  echo $db->f("id");
}

produces following rows in my postgresql logfile

010425.16:56:44.623 [7629] InitPostgres
010425.16:56:44.635 [7629] reset_client_encoding()..
010425.16:56:44.635 [7629] reset_client_encoding() done.
010425.16:56:44.635 [7629] StartTransactionCommand
010425.16:56:44.635 [7629] query: select getdatabaseencoding()
010425.16:56:44.639 [7629] ProcessQuery
010425.16:56:44.639 [7629] CommitTransactionCommand
010425.16:56:44.640 [7629] StartTransactionCommand
010425.16:56:44.640 [7629] query: SELECT id FROM xyz;
010425.16:56:44.646 [7629] ProcessQuery
010425.16:56:44.647 [7629] CommitTransactionCommand

But what i need is this (only with direct php functions)

  $conn = pg_Connect ("dbname=xyz user=abc password=012 host=localhost
port=5432");
  $result = pg_exec ($conn, "SELECT * FROM races");
  $num = pg_numrows($result);

  for ($i=0; $i<$num; $i++) {
    $r = pg_fetch_row($result, $i);

   for ($j=0; $j<count($r); $j++) {
     echo "$r[$j]&nbsp;";
   }

this code produces the same following log, but this 3 line are append

010425.16:51:27.981 [7560] proc_exit(0) // this 3 rows
finish the backend process
010425.16:51:27.981 [7560] shmem_exit(0)
010425.16:51:27.981 [7560] exit(0)

Can someone help me to modify the phplib, that i can close the backend
right after i finished the webpage??
Any ideas??

thx

Konstantin

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>