PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8
pg_fetch_result - Returns values from a result instance
Code Examples

pg_fetch_result( PgSql\Result$result, int$row, mixed$field ): string|false|null
stringfalsenullpg_fetch_result PgSql\Resultresult mixedfield



An PgSql\Result instance, returned by pg_query, pg_query_params or pg_execute(among others).


Row number in result to fetch. Rows are numbered from 0 upwards. If omitted, next row is fetched.


A string representing the name of the field (column) to fetch, otherwise an int representing the field number to fetch. Fields are numbered from 0 upwards.

Return Values

Boolean is returned as "t" or "f". All other types, including arrays are returned as strings formatted in the same default PostgreSQL manner that you would see in the psql program. Database NULL values are returned as null.

false is returned if row exceeds the number of rows in the set, or on any other error.


Version Description
8.1.0 The result parameter expects an PgSql\Result instance now; previously, a resource was expected.

Related Functions

Example of pg_fetch_result

Show all examples for pg_fetch_result

PHP Version:

Function pg_fetch_result:

PostgreSQL Functions

Most used PHP functions