To retrieve records from the database, we can use the same functions that we used to
INSERT records into a database, except
pg_insert(). To retrieve the records or to navigate tuples one by one, we need to use some other functions where we can traverse the complete query result set.
Now let's discuss query retrieval functions one by one.
Once we execute our SQL query using
pg_query_params, we can use
pg_fetch_all; this takes the data resource as an argument and returns an array, which holds our complete query result set.
The following is an example:
<?php ... $con=getDBConnection(); $res=pg_query($con, "SELECT * FROM test"); $arr=pg_fetch_all($res); echo"Complete result set\n"; print_r($arr); ?>
In the preceding PHP code, we used
$res as an argument for
pg_fetch_all(). which is a pointer to the query result set.
$ php /tmp/test.php Successfully made connection...