1 # pq\Cursor pq\Connection::declare(string $name, int $flags, string $query)
3 Declare a cursor for a query.
8 The identifying name of the cursor.
10 Any combination of pq\Cursor constants.
12 The query for which to open a cursor.
16 * pq\Cursor, an open cursor instance.
20 * pq\Exception\InvalidArgumentException
21 * pq\Exception\RuntimeException
22 * pq\Exception\BadMethodCallException
28 $connection = new pq\Connection;
30 $cursor = $connection->declare("example", pq\Cursor::WITH_HOLD,
31 "SELECT * FROM generate_series(0,29) s WHERE (s%2)=0");
33 for ( $result = $cursor->fetch(2);
35 $cursor->move(1), $result = $cursor->fetch(2)) {
36 foreach ($result as $row) {
37 foreach ($row as $col) {