PostgreSQL link resources

From: Date: Wed, 20 Dec 2000 17:43:28 +0000
Subject: PostgreSQL link resources
Groups: php.general 
Request: Send a blank email to php-general+get-31256@lists.php.net to get a copy of this message
Hello, the following piece of code fails on execution with PHP 4.0.x. Is this a bug or is there an explanation on this undefined behaviour? All db queries should succeed, but the last one (and its pg_close statement) return an error, listed below. It works when passing the $db_id through all levels, or probably by using persistant connections (don't know) - but both are not a real alternative. Josef <?php function level3() { $db_id = pg_connect("host=localhost dbname=tesql user=foo password=bar"); $db_resid = pg_exec($db_id, "SELECT * FROM tesqltable"); pg_close($db_id); } function level2() { $db_id = pg_connect("host=localhost dbname=tesql user=foo password=bar"); $db_resid = pg_exec($db_id, "SELECT * FROM tesqltable"); level3(); $db_resid1 = pg_exec($db_id, "SELECT * FROM tesqltable"); // NO ERROR! pg_close($db_id); } $db_id = pg_connect("host=localhost dbname=tesql user=foo password=bar"); $db_resid = pg_exec($db_id, "SELECT * FROM tesqltable"); level2(); $db_resid = pg_exec($db_id, "SELECT * FROM tesqltable"); // ERROR! pg_close($db_id); // ERROR! echo "PHP PostgreSQL function failed test, did it?\n"; // 1 is not a valid PostgreSQL link resource in ... ?>

« previous php.general (#31256) next »