Query: pg_fetch_assoc
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
PG_FETCH_ASSOC(3) PG_FETCH_ASSOC(3) pg_fetch_assoc - Fetch a row as an associative arraySYNOPSISarray pg_fetch_assoc (resource $result, [int $row])DESCRIPTIONpg_fetch_assoc(3) returns an associative array that corresponds to the fetched row (records). pg_fetch_assoc(3) is equivalent to calling pg_fetch_array(3) with PGSQL_ASSOC as the optional third parameter. It only returns an associa- tive array. If you need the numeric indices, use pg_fetch_row(3). Note This function sets NULL fields to the PHP NULL value. pg_fetch_assoc(3) is NOT significantly slower than using pg_fetch_row(3), and is significantly easier to use.PARAMETERSo $result - PostgreSQL query result resource, returned by pg_query(3), pg_query_params(3) or pg_execute(3) (among others). o $row - Row number in result to fetch. Rows are numbered from 0 upwards. If omitted or NULL, the next row is fetched.RETURN VALUESAn array indexed associatively (by field name). Each value in the array is represented as a string. Database NULL values are returned as NULL. FALSE is returned if $row exceeds the number of rows in the set, there are no more rows, or on any other error.EXAMPLESExample #1 pg_fetch_assoc(3) example <?php $conn = pg_connect("dbname=publisher"); if (!$conn) { echo "An error occurred. "; exit; } $result = pg_query($conn, "SELECT id, author, email FROM authors"); if (!$result) { echo "An error occurred. "; exit; } while ($row = pg_fetch_assoc($result)) { echo $row['id']; echo $row['author']; echo $row['email']; } ?>SEE ALSOpg_fetch_row(3), pg_fetch_array(3), pg_fetch_object(3), pg_fetch_result(3). PHP Documentation Group PG_FETCH_ASSOC(3)
Related Man Pages |
---|
msql_fetch_array(3) - php |
sqlsrv_fetch(3) - php |
mysqli_fetch_assoc(3) - php |
pg_fetch_array(3) - php |
pg_field_prtlen(3) - php |