From: | Gerd Terlutter <gerd(at)MplusB(dot)de> |
---|---|
To: | David Busby <busby(at)pnts(dot)com> |
Cc: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: PHP Connections |
Date: | 2003-08-06 08:23:16 |
Message-ID: | 3F30BAF4.9040301@MplusB.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
David Busby wrote:
> List,
> Which way to connect is better for my scripts?
>
> a global
> $db = pg_connect('asdfasdfasdfasdf');
> and every function can have
> global $db;
> at the top?
>
> or like this?
>
> function db_handle()
> {
> return pg_connect('asdfasdfasdfasdfadsf');
> }
>
> and everyplace needed use `db_handle()` so I call pg_exec like
>
> $rs = pg_exec(db_handle(),"select everything from everywhere"));
>
> So does that db_handle() make a new connection each time?
> I'm really looking for the way to optimise my connection usage.
>
the glob is better when you use it undefined times in each of your
script. another way is
$dbh = db_handle();
$dbh->doThis(param);
$dbh->doThat(param);
or perhaps write an own class with specials for your page. e.g.
functions like update, getFrom, insertInto, deleteFrom.
best regards,
Gerd
--
--------------------------------------------------------
# Gerd Terlutter | Mueller+Blanck Software GmbH #
# gerd(at)MplusB(dot)de | Gutenbergring 38 #
# gerd(dot)terlutter(at)web(dot)de | D-22848 Noderstedt #
# tel:0171/6992579 | tel:+49 40 500 171-1 #
# Buero:040/500171-17 | fax:+49 40 500 171-71 #
--------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Schmitz | 2003-08-06 12:59:22 | Using Cursors in PHP |
Previous Message | Pawel Szczesny | 2003-08-05 22:30:31 | Re: undefined symbol: SortMem |