【问题标题】:fetch a single postgres record as an associative array without using while loop在不使用 while 循环的情况下获取单个 postgres 记录作为关联数组
【发布时间】:2013-03-03 04:55:23
【问题描述】:

如果我有一个我知道只会返回一个结果的语句:

$emp_query = "SELECT * FROM table WHERE id = 'employee_id' LIMIT 1"

有什么方法可以在不使用pg_fetch_assoc 和while 循环的情况下将pg_query($con, $csr_query); 的结果作为关联数组访问?当我知道我只检索一条记录时,while 循环似乎是不必要的。也许 PDO 中也有一些方法,我只是先这样设置它,因为我更喜欢简单的方法。谢谢。

【问题讨论】:

    标签: php sql postgresql pdo


    【解决方案1】:

    类似 pg_fetch_result 的东西:

    http://www.php.net/manual/en/function.pg-fetch-result.php

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-01
      • 1970-01-01
      • 2018-06-02
      • 2010-12-08
      • 1970-01-01
      • 2013-05-19
      • 1970-01-01
      相关资源
      最近更新 更多