pg_num_fields

Returns the number of fields in a result

&reftitle.description; `int` `pg_num_fields` `PgSql\Result` `result`

`pg_num_fields` returns the number of fields (columns) in the `PgSql\Result` instance.

This function used to be called `pg_numfields`.

&reftitle.parameters;

`result`

- &pgsql.parameter.result;
&reftitle.returnvalues;

The number of fields (columns) in the result. On error, -1 is returned.

&reftitle.changelog;

&Version; | &Description;
&pgsql.changelog.result-object;

&reftitle.examples;

### `pg_num_fields` example

    <?php
    $result = pg_query($conn, "SELECT 1, 2");

    $num = pg_num_fields($result);

    echo $num . " field(s) returned.\n";
    ?>

&example.outputs;

    2 field(s) returned.

&reftitle.seealso;

- `pg_num_rows`
- `pg_affected_rows`