[英]fetch a single postgres record as an associative array without using while loop
If I have a statement that I know will return only one result: 如果我有一条声明,我知道将仅返回一个结果:
$emp_query = "SELECT * FROM table WHERE id = 'employee_id' LIMIT 1
" $emp_query = "SELECT * FROM table WHERE id = 'employee_id' LIMIT 1
”
Is there any way I can access the result of pg_query($con, $csr_query);
有什么办法可以访问
pg_query($con, $csr_query);
as an associative array without using a pg_fetch_assoc
and a while loop? 作为关联数组而不使用
pg_fetch_assoc
和while循环? A while loop seems unnecessary when I know I'm retrieving only one record. 当我知道只检索一条记录时,似乎不需要进行while循环。 Maybe there is some way in PDO as well, I'm just setting it up this way first because I'm more comfortable with the simple way.
也许PDO中也有某种方法,我只是首先以这种方式进行设置,因为我对简单方法更满意。 Thanks.
谢谢。
Something like pg_fetch_result: 像pg_fetch_result这样的东西:
http://www.php.net/manual/en/function.pg-fetch-result.php http://www.php.net/manual/zh/function.pg-fetch-result.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.