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 ";
    }
});