PHP.nl

pg_fetch_result

pg_fetch_result

Returns values from a result instance

 **pg_fetch_result** PgSql\Result $result  $row mixed $field
 **pg_fetch_result** PgSql\Result $result mixed $field
returns the value of a particular

row and field (column) in an instance. pg_fetch_result``PgSql\Result

Opmerking: > This function used to be called . pg_result

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

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

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 program. Database values are returned as null. NULL

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

Voorbeeld: example

<?php
$db = pg_connect("dbname=users user=me");

$res = pg_query($db, "SELECT 1 UNION ALL SELECT 2");

$val = pg_fetch_result($res, 1, 0);

echo "First field in the second row is: ", $val, "\n";
?>
First field in the second row is: 2

pg_query``pg_fetch_array