RE: [PHP] Connection to postgresql DB used by 2 scripts ?
| From: | Picard, Cyril | Date: | Wed, 18 Apr 2001 11:58:01 +0000 |
| Subject: | RE: [PHP] Connection to postgresql DB used by 2 scripts ? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-49184@lists.php.net to get a copy of this message | ||
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:johannes.janson@gmx.de]
> Date: mercredi 18 avril 2001 12:42
> À: php-general@lists.php.net
> 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"" <cyril.picard@eads-dsn.com> schrieb im Newsbeitrag
>
> news:B5CDCF382265D311BF33009027A8FE9401E6F3BD@pmrmsg.edsn.com...
> > 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: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net