ocifetchstatement
(PHP 3>= 3.0.8, PHP 4 )
ocifetchstatement -- Fetch all rows of result data into an array
Description
int
ocifetchstatement ( resource stmt, array &output [, int skip [, int maxrows [, int flags]]])
ocifetchstatement() fetches rows from a result set
into a user-defined array. skip is the
number of initial rows to ignore when fetching the result (default value
of 0, to start at the first line). maxrows is the
number of rows to read, starting at the skipth row
(default is -1, meaning all rows).
flags represents the available options for,
which can be any combination of the following :
|
OCI_FETCHSTATEMENT_BY_ROW
|
|
OCI_FETCHSTATEMENT_BY_COLUMN (default value)
|
|
OCI_NUM
|
|
OCI_ASSOC
|
Example 1. ocifetchstatement() example
<?php /* OCIFetchStatement example mbritton at verinet dot com (990624) */
$conn = OCILogon("scott", "tiger");
$stmt = OCIParse($conn, "select * from emp");
OCIExecute($stmt);
$nrows = OCIFetchStatement($stmt, $results); if ($nrows > 0) { echo "<table border=\"1\">\n"; echo "<tr>\n"; while (list($key, $val) = each($results)) { echo "<th>$key</th>\n"; } echo "</tr>\n"; for ($i = 0; $i < $nrows; $i++) { reset($results); echo "<tr>\n"; while ($column = each($results)) { $data = $column['value']; echo "<td>$data[$i]</td>\n"; } echo "</tr>\n"; } echo "</table>\n"; } else { echo "No data found<br />\n"; } echo "$nrows Records Selected<br />\n"; OCIFreeStatement($stmt); OCILogoff($conn); ?>
|
|