PG_FIELD_NUM(3) PG_FIELD_NUM(3)
pg_field_num - Returns the field number of the named field
SYNOPSIS
int pg_field_num (resource $result, string $field_name)
DESCRIPTION
pg_field_num(3) will return the number of the field number that corresponds to the $field_name in the given PostgreSQL $result resource.
Note
This function used to be called pg_fieldnum(3).
PARAMETERS
o $result
- PostgreSQL query result resource, returned by pg_query(3), pg_query_params(3) or pg_execute(3) (among others).
o $field_name
- The name of the field.
RETURN VALUES
The field number (numbered from 0), or -1 on error.
EXAMPLES
Example #1
Getting information about fields
<?php
$dbconn = pg_connect("dbname=publisher") or die("Could not connect");
$res = pg_query($dbconn, "select author, year, title from authors where author = 'Orwell'");
echo "Column 'title' is field number: ", pg_field_num($res, 'title');
?>
The above example will output:
Column 'title' is field number: 2
SEE ALSO
pg_field_name(3).
PHP Documentation Group PG_FIELD_NUM(3)