Received: from tomts8-srv.bellnexxia.net (tomts8.bellnexxia.net [209.226.175.52]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0BJxgB15759 for ; Fri, 11 Jan 2002 14:59:42 -0500 (EST) (envelope-from fbax@sympatico.ca) Received: from ACER ([65.93.1.15]) by tomts8-srv.bellnexxia.net (InterMail vM.4.01.03.16 201-229-121-116-20010115) with SMTP id <20020111195943.GNUC16860.tomts8-srv.bellnexxia.net@ACER>; Fri, 11 Jan 2002 14:59:43 -0500 Message-Id: <3.0.6.32.20020111145850.01cb7440@pop6.sympatico.ca> X-Sender: b1wudu74@pop6.sympatico.ca X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Fri, 11 Jan 2002 14:58:50 -0500 To: Adam Haberlach From: Frank Bax Subject: Re: passing resource id's through functions Cc: pgsql-php@postgresql.org In-Reply-To: <20020111103327.A28869@newsnipple.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Archive-Number: 200201/13 X-Sequence-Number: 820 At 10:33 AM 1/11/02 -0800, Adam Haberlach wrote: >On Fri, Jan 11, 2002 at 10:44:05AM -0500, Chadwick Rolfs wrote: >> I seem to have figured out that pg_connect returns a resource ID that will >> not pass into another function, and that pg_pconnect does. I'm not too >> keen on the persistent connections. Can someone confirm this belief? I'm >> trying to remember where on php.net I read how to pass pg_connect >> resources to other functions, and haven't found it at functions, >> persistent connections, pg_connect or pg_pconnect. > > Hmm--I've never had any problems with passing the database connection >handle from pg_connect into pg_exec (the only place you can really use it, >as far as I know). The problem is not with passing the connection hanlde to pg_exec exactly. If you create the connection hanlde in one function, then pass that handle to another function that actually does the call to pg_exec, then sometimes there are problems. In my own case, I figured out if after creating the connection hanlde, I call two functions that each call pg_exec, then this normally works, but when a function makes two calls to pg_exec, then the NEXT function has a problem. $dbc = pg_connect(); func1($dbc); func2($dbc); This works fine if func1() and func2() each contain a single call to pg_exec. If func1() contains two calls to pg_exec(), then func2 fails on call to pg_exec. I should also point out, that this was never a problem before I did upgrades in October. Unfortunately, I upgraded OpenBSD, pgsql, php(3->4) and phplib all during the same week. Frank