By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,968 Members | 1,684 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,968 IT Pros & Developers. It's quick & easy.

Using PostgreSQL with PHP / Scope an Lifetime of $result

P: n/a
Hi !

The following PHP-Code:
$conn=pg_connect ($conn_string); $query=pg_exec ($conn, $sql_statement); // it's pg_query for PHP

4.2.0

pg_close ($conn);


My question:

What's the scope and lifetime of the $query Resource ? Can I still use it
after calling pg_close ? or do i have to copy all my rows, fields and stuff
before calling pg_close.

Suppose I'd use the mentioned Code in a function wich will return $query as
a result. Will the return value of the function still be valid and usable ?

Thanks for your help !

Martin

please reply to: mN*******************@web.de remove NO_SPAM to get the
email adress
Jul 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ljb
mN*******************@web.de wrote:
Hi !

The following PHP-Code:
$conn=pg_connect ($conn_string); $query=pg_exec ($conn, $sql_statement); // it's pg_query for PHP

4.2.0

pg_close ($conn);


My question:

What's the scope and lifetime of the $query Resource ? Can I still use it
after calling pg_close ? or do i have to copy all my rows, fields and stuff
before calling pg_close.

Suppose I'd use the mentioned Code in a function wich will return $query as
a result. Will the return value of the function still be valid and usable ?


The result resource should be valid even after the link to the database is
closed. (At least, the libpq documentation says so.) PHP should keep the
resource valid until it is explicitly freed with pg_free_result, or until
the resource variable goes out of scope. So if it is only local to a
function, the resource is freed when the function returns, but if the
function returns the resource then the resource is still valid in the
caller's context.
Jul 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.