views:

82

answers:

1

Just a little confused here...

I have a function in postgres, and when I'm at the pg prompt, I just do:

SELECT zp('zc',10,20,90);
FETCH ALL FROM zc;

I'm wondering how to do this from php?

I thought I could just do:

$q = pg_query("SELECT zp('zc',10,20,90)");

But, how do I "fetch" from that query?

A: 

Just send the FETCH-query to the database:

$result = pg_query("FETCH ALL FROM zc;");

You can now use a while-loop to fetch all the results in $result or just just pg_fetch_all() to fetch in PHP.

Frank Heikens
I see... So, I put in *both* queries? First, the function call, and then the fetch?
KittyYoung
Looks like your function returns a cursor, so you need two queries to receive the result.
Frank Heikens
Ok, thanks. I appreciate the guidance and the ability to dumb things down for a newb. :)
KittyYoung