include will help me to organize my scripts, but it will effectively
establish the connection each time I perform the query.
I would like to establish the connection one time, and then to be able to
perform many queries using this connection.
I've been told that i could declare $conn as global in both script : 
-- connect.php:
   global $conn;
   $conn = pg_connect ...

-- query.php:
   global $conn;
   $res = pg_exec( $conn, ... 

What do you think about this way ?

> -----Message d'origine-----
> De:   Johannes Janson [SMTP:[EMAIL PROTECTED]]
> Date: mercredi 18 avril 2001 12:42
> À:    [EMAIL PROTECTED]
> Objet:        Re: [PHP] Connection to postgresql DB used by 2 scripts ?
> 
> Hi,
> 
> put: include("connect.php"); at the beginning of query.php.
> 
> Johannes
> 
> ""Picard, Cyril"" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > I would like to query a postgresql db with the php language.
> > Today I wrote a script (connectandquery.php) performing the following :
> > - connect to the DB : $conn = pg_Connect("dbname = foo");
> > - execute the query : $res = pg_Exec($conn,"SELECT * from BAR");
> >
> >
> > But I would like to write this in two scripts :
> > - connect.php : $conn = pg_Connect("dbname = foo");
> > - query.php : $res = pg_Exec($conn,"SELECT * from BAR");
> >
> > but I don't know how to get the $conn variable (defined in connect.php)
> in
> > the script query.php.
> >
> > Any idea is welcome !
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to