class Cursor (View source)

Declare a cursor.

Constants

BINARY

Causes the cursor to return data in binary rather than in text format. You probably do not want to use that.

INSENSITIVE

The data returned by the cursor should be unaffected by updates to the tables underlying the cursor that take place after the cursor was opened.

WITH_HOLD

The cursor should stay usable after the transaction that created it was successfully committed.

SCROLL

Force that rows can be retrieved in any order from the cursor.

NO_SCROLL

Force that rows are only retrievable in sequiential order.

NOTE: See the notes in the official PostgreSQL documentation for more information.

Properties

Connection read-only $connection

The connection the cursor was declared on.

string read-only $name

The identifying name of the cursor.

Methods

__construct(Connection $connection, string $name, int $flags, string $query, bool $async)

Declare a cursor.

close()

Close an open cursor.

closeAsync()

[Asynchronously](pq/Connection/: Asynchronous Usage) close an open cursor.

fetch(string $spec = "1")

Fetch rows from the cursor.

fetchAsync(string $spec = "1", callable $callback = null)

[Asynchronously](pq/Connection/: Asynchronous Usage) fetch rows from the cursor.

move(string $spec = "1")

Move the cursor.

moveAsync(string $spec = "1", callable $callback = null)

[Asynchronously](pq/Connection/: Asynchronous Usage) move the cursor.

open()

Reopen a cursor.

openAsync()

[Asynchronously](pq/Connection/: Asynchronous Usage) reopen a cursor.

Details

__construct(Connection $connection, string $name, int $flags, string $query, bool $async)

Declare a cursor.

See pq\Connection::declare().

Parameters

Connection $connection

The connection on which the cursor should be declared.

string $name

The name of the cursor.

int $flags

See pq\Cursor constants.

string $query

The query for which the cursor should be opened.

bool $async

Whether to declare the cursor [asynchronously](pq/Connection/: Asynchronous Usage).

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

close()

Close an open cursor.

This is a no-op on already closed cursors.

closeAsync()

[Asynchronously](pq/Connection/: Asynchronous Usage) close an open cursor.

See pq\Cursor::close().

Result fetch(string $spec = "1")

Fetch rows from the cursor.

See pq\Cursor::move().

Parameters

string $spec

What to fetch.

Fetch argument:

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

Return Value

Result

the fetched row(s).

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

fetchAsync(string $spec = "1", callable $callback = null)

[Asynchronously](pq/Connection/: Asynchronous Usage) fetch rows from the cursor.

See pq\Cursor::fetch().

Parameters

string $spec

What to fetch.

callable $callback

as function(pq\Result $res) A callback to execute when the result is ready.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

Result move(string $spec = "1")

Move the cursor.

See pq\Cursor::fetch().

Parameters

string $spec

What to fetch.

Fetch argument:

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

Return Value

Result

command status.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

moveAsync(string $spec = "1", callable $callback = null)

[Asynchronously](pq/Connection/: Asynchronous Usage) move the cursor.

See pq\Cursor::move().

Parameters

string $spec

What to fetch.

callable $callback

as function(pq\Result $res) A callback to execute when the command completed.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

open()

Reopen a cursor.

This is a no-op on already open cursors.

NOTE: Only cursors closed by pq\Cursor::close() will be reopened.

openAsync()

[Asynchronously](pq/Connection/: Asynchronous Usage) reopen a cursor.

See pq\Cursor::open().