X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B321BD1C4C1 for ; Wed, 6 Aug 2003 08:23:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 99256-03 for ; Wed, 6 Aug 2003 05:22:14 -0300 (ADT) Received: from lighthouse.MplusB.de (lighthouse.MplusB.de [193.102.49.10]) by svr1.postgresql.org (Postfix) with ESMTP id 28444D1C4B7 for ; Wed, 6 Aug 2003 05:23:22 -0300 (ADT) Received: from [193.102.49.130] (helo=compass.MplusB.de) by lighthouse.MplusB.de with esmtp (Exim 3.35 #1 (Debian)) id 19kJZl-0005S3-00; Wed, 06 Aug 2003 10:23:17 +0200 Received: from MplusB.de (gerd@sloop.MplusB.de [193.102.49.177]) by compass.MplusB.de (8.9.3p2/8.9.3/Debian 8.9.3-21) with ESMTP id KAA09287; Wed, 6 Aug 2003 10:23:17 +0200 X-Authentication-Warning: compass.MplusB.de: Host gerd@sloop.MplusB.de [193.102.49.177] claimed to be MplusB.de Message-ID: <3F30BAF4.9040301@MplusB.de> Date: Wed, 06 Aug 2003 10:23:16 +0200 From: Gerd Terlutter User-Agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.0.2) Gecko/20030401 Debian/1.0.2-2 X-Accept-Language: de-de MIME-Version: 1.0 To: David Busby Cc: pgsql-php@postgresql.org Subject: Re: PHP Connections References: <009601c35b79$48810010$1100000a@busbydev> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/13 X-Sequence-Number: 2190 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@MplusB.de | Gutenbergring 38 # # gerd.terlutter@web.de | D-22848 Noderstedt # # tel:0171/6992579 | tel:+49 40 500 171-1 # # Buero:040/500171-17 | fax:+49 40 500 171-71 # --------------------------------------------------------