0

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?

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.