Skip to content

pg_fetch_result Shows Incorrect ArgumentCountError Message when Called With 1 Argument #17158

Closed
@it-all

Description

@it-all

Description

The following code:

<?php

// use any PgSql\Result $pgResult below
pg_fetch_result($pgResult);

Resulted in this output:

PHP Fatal error:  Uncaught ArgumentCountError: pg_fetch_result() expects exactly 3 arguments, 1 given

But I expected this output instead:

PHP Fatal error:  Uncaught ArgumentCountError: pg_fetch_result() expects 2 or 3 arguments, 1 given

[The documentation](https://www.php.net/manual/en/function.pg-fetch-result.php) is unclear, as it says the 2nd argument (row), may be omitted, but does not say the 3rd argument (field) may be omitted.
The code pg_fetch_result($pgResult, null); does work and returns the first field of the first row. 
I think the documentation needs to be updated as well as the error message.

PHP Version

PHP 8.3.14

Operating System

Ubuntu 24.04

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions