ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# Coroutine\\PostgreSQL->fetchObject 提取一行作为对象 ~~~ function Coroutine\PostgreSQL->fetchObject(resource $queryResult [, int $row); ~~~ example: ~~~ go(function () { $a = new Swoole\Coroutine\PostgreSQL(); $conn = $a -> connect ("host=127.0.0.1 port=5432 dbname=test user=wuzhenyu"); $result = $a->query('SELECT * FROM test;'); $row = 0; while ($data = $a->fetchObject($result, $row)) { echo $data->id . " \n "; $row++; } }); ~~~ 或者 ~~~ go(function () { $a = new Swoole\Coroutine\PostgreSQL(); $conn = $a -> connect ("host=127.0.0.1 port=5432 dbname=test user=wuzhenyu"); $result = $a->query('SELECT * FROM test;'); $row = 0; for ($row = 0 ;$row < $a->numRows($result);$row++){ $data = $a->fetchObject($result, $row); echo $data->id . " \n "; } }); ~~~