我需要在 PHP 中对 SQL 结果进行以下安排:
if (!$result) { echo "An error occurred.\n"; exit; } while($array = pg_fetch_array($result)) { $list = $array['list']; } pg_free_result($result);
但只有 pedro
在数组中返回。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
您需要 pg_fetch_assoc() 来获取返回的关联数组。
并且您需要建立一个数组来附加节点:
或者如果你只是想玩一下,可以使用 pg_fetch_all_columns()。
https://www.php.net /manual/en/function.pg-fetch-all-columns.php
0 表示行中的第一列。