Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ingres_fetch_array(3) [php man page]

INGRES_FETCH_ARRAY(3)							 1						     INGRES_FETCH_ARRAY(3)

ingres_fetch_array - Fetch a row of result into an array

SYNOPSIS
array ingres_fetch_array (resource $result, [int $result_type]) DESCRIPTION
This function is an extended version of ingres_fetch_row(3). In addition to storing the data in the numeric indices of the result array, it also stores the data in associative indices, using the field names as keys. If two or more columns of the result have the same field names, the last column will take precedence. To access the another column or col- umns of the same name, you must use the numeric index of the column or make an alias for the column. For example: <?php $result = ingres_query($link, "select ap_place as city, ap_ccode as country from airport where ap_iatacode = 'VLL'"); $result = ingres_fetch_array($result); $foo = $result["city"]; $bar = $result["country"]; ?> With regard to speed, the function is identical to ingres_fetch_object(3), and almost as quick as ingres_fetch_row(3) (the difference is insignificant). By default, arrays created by ingres_fetch_array(3) start from position 1 and not 0 as with other DBMS extensions. The starting position can be adjusted to 0 using the configuration parameter ingres.array_index_start. Note Related Configurations See also the ingres.array_index_start, ingres.fetch_buffer_size and ingres.utf8 directives in Runtime Configuration. PARAMETERS
o $result - The query result identifier o $result_type - The result type. This $result_type can be INGRES_NUM for enumerated array, INGRES_ASSOC for associative array, or INGRES_BOTH (default). RETURN VALUES
Returns an array that corresponds to the fetched row, or FALSE if there are no more rows EXAMPLES
Example #1 Fetch a row of result into an array <?php $link = ingres_connect($database, $user, $password); $result = ingres_query($link,"select * from table"); while ($row = ingres_fetch_array($result)) { echo $row["user_id"]; // using associative array echo $row["fullname"]; echo $row[1]; // using enumerated array echo $row[2]; } ?> SEE ALSO
ingres_query(3), ingres_num_fields(3), ingres_field_name(3), ingres_fetch_assoc(3), ingres_fetch_object(3), ingres_fetch_row(3). PHP Documentation Group INGRES_FETCH_ARRAY(3)

Check Out this Related Man Page

PG_FETCH_ARRAY(3)														 PG_FETCH_ARRAY(3)

pg_fetch_array - Fetch a row as an array

SYNOPSIS
array pg_fetch_array (resource $result, [int $row], [int $result_type = PGSQL_BOTH]) DESCRIPTION
pg_fetch_array(3) returns an array that corresponds to the fetched row (record). pg_fetch_array(3) is an extended version of pg_fetch_row(3). In addition to storing the data in the numeric indices (field number) to the result array, it can also store the data using associative indices (field name). It stores both indicies by default. Note This function sets NULL fields to the PHP NULL value. pg_fetch_array(3) is NOT significantly slower than using pg_fetch_row(3), and is significantly easier to use. PARAMETERS
o $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. o $result_type - An optional parameter that controls how the returned array is indexed. $result_type is a constant and can take the following values: PGSQL_ASSOC, PGSQL_NUM and PGSQL_BOTH. Using PGSQL_NUM, pg_fetch_array(3) will return an array with numerical indices, using PGSQL_ASSOC it will return only associative indices while PGSQL_BOTH, the default, will return both numerical and associa- tive indices. RETURN VALUES
An array indexed numerically (beginning with 0) or associatively (indexed by field name), or both. 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. EXAMPLES
Example #1 pg_fetch_array(3) example <?php $conn = pg_pconnect("dbname=publisher"); if (!$conn) { echo "An error occurred. "; exit; } $result = pg_query($conn, "SELECT author, email FROM authors"); if (!$result) { echo "An error occurred. "; exit; } $arr = pg_fetch_array($result, 0, PGSQL_NUM); echo $arr[0] . " <- Row 1 Author "; echo $arr[1] . " <- Row 1 E-mail "; // As of PHP 4.1.0, the row parameter is optional; NULL can be passed instead, // to pass a result_type. Successive calls to pg_fetch_array will return the // next row. $arr = pg_fetch_array($result, NULL, PGSQL_ASSOC); echo $arr["author"] . " <- Row 2 Author "; echo $arr["email"] . " <- Row 2 E-mail "; $arr = pg_fetch_array($result); echo $arr["author"] . " <- Row 3 Author "; echo $arr[1] . " <- Row 3 E-mail "; ?> SEE ALSO
pg_fetch_row(3), pg_fetch_object(3), pg_fetch_result(3). PHP Documentation Group PG_FETCH_ARRAY(3)
Man Page