pg_fetch_result

FunctionParams changed in PHP 8.1

Returns values from a result instance.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1
Improved
PHP 8.2-8.3
PHP 8.4
PHP 8.5
PHP 8.6

pg_fetch_result Function synopsis

pg_fetch_result(
    PgSql\Result $result,
    $row,
    string|int $field = <default>
  ): string|false|null

Parameters

$result

TypePgSql\Result

$row

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

$field

OptionalTypestring|intDefault value

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 value

Typestring|false|null

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.

Changes to the pg_fetch_result Function

PHP 8.1

  • Parameter type added for parameter #1 ($result): PgSql\Result
  pg_fetch_result(
-     $result,
+     PgSql\Result $result,
      $row,
      string|int $field = <default>
    ): string|false|null

PHP 8.0

  • Return type added: string|false|null
  • Parameter name of parameter #2 changed: $row_number to $row
  • Parameter name of parameter #3 changed: $field_name to $field
  • Parameter type added for parameter #3 ($field): string|int
  • Parameter default value added for position #3 ($field): <default>
  pg_fetch_result(
      $result,
-     $row_number,
+     $row,
-     $field_name
+     string|int $field = <default>
-   )
+   ): string|false|null

pg_fetch_result Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported Yes
PHP 5.3Unsupported Yes