Unbuffered queries
Eric Chamberlain <[email protected]> Wed, 8 Jan 2014 13:53:46 -0600
| Newsgroups | gmane.comp.db.postgresql.php |
|---|---|
| Message-ID | <[email protected]> |
--_d4ca0d48-413d-47c8-8ba9-f2680f47c198_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
When using php_query()=2C is this buffering all of the results from the que=
ry into memory? If so=2C is there a parameter I can send to make it not buf=
fer the query? I've also seen comments suggesting that a cursor should be u=
sed. There doesn't seem to be any way to get access to the internal cursor =
used by the PHP pgsql libs... or are they referring to doing something like=
this:
$result =3D pg_query($conn=2C "BEGIN=3B DECLARE s CURSOR FOR SELECT * FROM =
users=3B FETCH ALL IN s=3B END=3B")=3B
And then after which I could do this:
while ($row =3D pg_fetch_assoc($result)) { ...}
I don't have a large enough result set in my development or QA environment =
to run this query within PHP to know if it works or not. Any suggestions wo=
uld be helpful. Thank you!
Eric Chamberlain =
--_d4ca0d48-413d-47c8-8ba9-f2680f47c198_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<style><!--
.hmmessage P
{
margin:0px=3B
padding:0px
}
body.hmmessage
{
font-size: 12pt=3B
font-family:Calibri
}
--></style></head>
<body class=3D'hmmessage'><div dir=3D'ltr'>When using php_query()=2C is thi=
s buffering all of the results from the query into memory? If so=2C is ther=
e a parameter I can send to make it not buffer the query? I've also seen co=
mments suggesting that a cursor should be used. There doesn't seem to be an=
y way to get access to the internal cursor used by the PHP pgsql libs... or=
are they referring to doing something like this:<div><br></div><div><font =
face=3D"Courier New">$result =3D pg_query($conn=2C "BEGIN=3B DECLARE s CURS=
OR FOR SELECT * FROM users=3B FETCH ALL IN s=3B END=3B")=3B</font><br><div>=
<br></div><div>And then after which I could do this:</div><div><br></div><d=
iv><font face=3D"Courier New">while ($row =3D pg_fetch_assoc($result)) {</f=
ont></div><div><font face=3D"Courier New"> =3B  =3B ...</font></div=
><div><font face=3D"Courier New">}</font></div></div><div><br></div><div>I =
don't have a large enough result set in my development or QA environment to=
run this query within PHP to know if it works or not. Any suggestions woul=
d be helpful. Thank you!</div><div><br></div><div>Eric Chamberlain</div> =
</div></body>
</html>=
--_d4ca0d48-413d-47c8-8ba9-f2680f47c198_--