🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 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 "; } }); ~~~