Re: passing resource id's through functions

From: Frank Bax <fbax(at)sympatico(dot)ca>
To: Adam Haberlach <adam(at)newsnipple(dot)com>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: passing resource id's through functions
Date: 2002-01-11 19:58:50
Message-ID: 3.0.6.32.20020111145850.01cb7440@pop6.sympatico.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

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

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Andrew McMillan 2002-01-12 04:02:00 Re: passing resource id's through functions
Previous Message Frank Bax 2002-01-11 19:45:53 Re: passing resource id's through functions