本文介绍了我如何从php中获取存储的postgres函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在postgres中有一个函数,当我在pg提示符时,我只是这样做:
SELECT zp('zc',10,20,90);
FETCH ALL FROM zc;
我想知道如何从php执行此操作?
我想我可以这样做:
$ q = pg_query (SELECT zp('zc',10,20,90));
但是,如何从该查询中获取?
解决方案
只需将FETCH查询发送到数据库:
$ result = pg_query(FETCH ALL FROM zc;);
您现在可以使用while循环获取$ result中的所有结果,或者仅使用pg_fetch_all )在PHP中获取。
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?
解决方案
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.
这篇关于我如何从php中获取存储的postgres函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!