pq\Result pq\Cursor::fetch([string $spec = “1”])

Fetch rows from the cursor. See pq\Cursor::move().

Params:

Fetch argument:

FETCH and MOVE usually accepts arguments like the following, where count is the number of rows:

See the official PostgreSQL documentaion for details.

Returns:

Throws:

Example:

<?php

$c = new pq\Connection;
$p = new pq\Cursor($c, "mycursor", pq\Cursor::WITH_HOLD,
    "SELECT * FROM generate_series(0,29) s WHERE (s%2)=0");

for ($r = $p->fetch(2); $r->numRows; $p->move(1), $r = $p->fetch(2)) {
    foreach ($r as $row) {
        foreach ($row as $col) {
            echo "  $col";
        }
        echo "\n";
    }
}

?>

Yields:

0
2
6
8
12
14
18
20
24
26