[PHP-DOC] Bug #10153 Updated: Resource lost on the way.. From: danbeck <email protected>
Date: 06/27/01

ID: 10153
Updated by: danbeck
Reported By: romolo <email protected>
Old-Status: Analyzed
Status: Closed
Bug Type: Documentation problem
Operating system:
PHP Version: 4.0 Latest CVS (04/04/2001)
Assigned To:
Comments:

Corrected in latest cvs documentation.

Previous Comments:
---------------------------------------------------------------------------

[2001-06-20 18:27:07] sniper <email protected>
I get this output (with php 4.0.6RC4):

1 Resource id #1
2 Resource id #1
3 Resource id #1
4 Resource id #1

Warning: 1 is not a valid PostgreSQL link resource in /www/apache/htdocs/pgsql.php on line 18

which is correct. The pg_connect() behaves the same way
as mysql_connect() ie, if connection to same database is
made with same arguments, no new connection is established
but the old one returned instead.

Reclassified as documentation problem.

--Jani

---------------------------------------------------------------------------

[2001-04-04 05:09:29] romolo <email protected>
Executing this script generate the error:
Warning: 1 is not a valid PostgreSQL link resource in test.php on line 24
The main problem is that adding a little bit of code to php source to printout the refcount of the resource just after the pg_connect get executed and zend_list_addref get called
and just before the pg_exec get really executed i obtain the output at the end of the script, please not how refcount magically decrease between the pg_connect and the pg_exec.

The script...
<?php
//
// Test script to show the bug
//
$db1=pg_connect("dbname=test");
$res1=pg_exec($db1,"SELECT * from tbltest");
echo "1 ".$db1."<br>";

$db=pg_connect("dbname=test");
$res1=pg_exec($db,"SELECT * from tbltest");
echo "2 ".$db."<br>";
pg_close($db);

$db=pg_connect("dbname=test");
$res1=pg_exec($db,"SELECT * from tbltest");
echo "3 ".$db."<br>";
pg_close($db);

$db=pg_connect("dbname=test");
$res1=pg_exec($db,"SELECT * from tbltest");
echo "4 ".$db."<br>";
pg_close($db);

pg_close($db1);

?>

The output:

Warning: Refcount 2 in /usr/local/httpd/htdocs/test.php on line 6
1 Resource id #1
Warning: Refcount 3 in /usr/local/httpd/htdocs/test.php on line 9
Warning: Refcount 3 in /usr/local/httpd/htdocs/test.php on line 10
2 Resource id #1
Warning: Refcount 3 in /usr/local/httpd/htdocs/test.php on line 14
Warning: Refcount 3 in /usr/local/httpd/htdocs/test.php on line 15
3 Resource id #1
Warning: Refcount 3 in /usr/local/httpd/htdocs/test.php on line 19
Warning: Refcount 2 in /usr/local/httpd/htdocs/test.php on line 20
4 Resource id #1
Warning: 1 is not a valid PostgreSQL link resource in
   /usr/local/httpd/htdocs/test.php on line 24

---------------------------------------------------------------------------

ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=10153&edit=2