php8.5
Home/ Manual/ pgsql / functions/ pg_result_seek

pg_result_seek

PHP function Edit on GitHub ✎

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

Set internal row offset in result instance

Description

pg_result_seek(PgSql\Result $result, int $row): bool

pg_result_seek() sets the internal row offset in the result instance.

Parameters

result

Result

row

Row to move the internal offset to in the PgSql\Result instance. Rows are numbered starting from zero.

Return Values

Success

Changelog

VersionDescription

Examples

pg_result_seek() example

php
<?php

// Connect to the database
$conn = pg_pconnect("dbname=publisher");

// Execute a query
$result = pg_query($conn, "SELECT author, email FROM authors");

// Seek to the 3rd row (assuming there are 3 rows)
pg_result_seek($result, 2);

// Fetch the 3rd row
$row = pg_fetch_row($result);
 
?>

See Also

Source: reference/pgsql/functions/pg-result-seek.xml · from the official PHP manual (php/doc-en)