postgresql connection index propogating through function calls

From: Date: Tue, 28 Nov 2000 22:02:31 +0000
Subject: postgresql connection index propogating through function calls
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-27688@lists.php.net to get a copy of this message
Following situation is giving me a problem. First our file that includes data functions and other stuff so we only have to update one file. <?#FileIncludes.php < File number 1 $dbhost="localhost"; $dbport="5432"; $dbopt=""; $dbtty=""; $dbname="mypgdatabase"; function GetThis() { $query = "insert into db_table values('World')"; $result = pg_exec($database,$query); #generates error - no database connection index exists } function GetThat($database) { $query = "insert into db_table values('Hello')"; $result = pg_exec($database,$query); #success does not generate error GetThis(); # generates error - no database pointer } ?> Now the file that calls the functions... <?#PhpFile.php < File number 2 include("FileIncludes.php"); $database=pg_connect($dbhost,$dbport,$dbopt,$dbtty,$dbname); #yes, antequated style # calls to the database using this pointer but not in a function work normally GetThis(); #Call the function which contain a database call - cant use the pointer GetThat($database); #Call the function can use the pointer, but nested calls dont work ?> Should not the initial database connection index be valid for all pg_exec calls even if nexted within functions? Cannot get nexted functions to respond to the pointer at all even when the $datanase variable is passed through each nested function call (am I still making sense?). Appreciate any input. Dave

« previous php.general (#27688) next »