From: | "Luis H(dot)" <pgsql-novice(at)geekhouse(dot)no-ip(dot)com> |
---|---|
To: | <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Using PostgreSQL with PHP / Scope an Lifetime of $result |
Date: | 2003-08-26 19:35:13 |
Message-ID: | 004201c36c09$2c550260$0301a8c0@bigbertha |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
I just did a test, and the following order works fine:
$conn=pg_connect ($conn_string);
$query=pg_exec ($conn, $sql_statement);
pg_close ($conn);
while($row=pg_fetch_row($query)){
//do something with the data
}
----- Original Message -----
From: Eft, Aaron
To: 'Luis H.' ; pgsql-novice(at)postgresql(dot)org
Sent: Tuesday, August 26, 2003 3:16 PM
Subject: RE: [NOVICE] Using PostgreSQL with PHP / Scope an Lifetime of $result
As I remember, you should call pg_fetch_row before closing the connection. Like
$conn=pg_connect ($conn_string);
$query=pg_exec ($conn, $sql_statement);
$row=pg_fetch_row($query);
pg_close ($conn);
Then you can reference the $row[$i] in the resultset. If you try to reference the $query, it will try to execute it again. And with the connection closed, this would bomb out.
-----Original Message-----
From: Luis H. [mailto:pgsql-novice(at)geekhouse(dot)no-ip(dot)com]
Sent: Tuesday, August 26, 2003 11:52 AM
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: [NOVICE] Using PostgreSQL with PHP / Scope an Lifetime of $result
After you execute the pg_exec, the results are stored in $query and no longer have any direct reference to the database. So you can close the connection and still work with the query. I would assume you can return the $query and continue to work on it as long as you'd like.
http://us4.php.net/manual/en/function.pg-query.php
----- Original Message -----
From: Martin Ziebart
To: pgsql-novice(at)postgresql(dot)org
Sent: Monday, August 25, 2003 5:07 PM
Subject: [NOVICE] Using PostgreSQL with PHP / Scope an Lifetime of $result
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: mNO_SPAMartin_ziebart(at)web(dot)de remove NO_SPAM to get the email adress
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2003-08-26 19:35:25 | Re: Can the following be done? |
Previous Message | Eft, Aaron | 2003-08-26 19:16:44 | Re: Using PostgreSQL with PHP / Scope an Lifetime of $re |