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 all the rows from a result into a user-defined array. ocifetchstatement() returns the number of rows fetched. 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 to -1, meaning all the rows).
flags represents the available options for, which can be any combinaisons 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 ) {
print "<TABLE BORDER=\"1\">\n";
print "<TR>\n";
while ( list( $key, $val ) = each( $results ) ) {
print "<TH>$key</TH>\n";
}
print "</TR>\n";
for ( $i = 0; $i < $nrows; $i++ ) {
reset($results);
print "<TR>\n";
while ( $column = each($results) ) {
$data = $column['value'];
print "<TD>$data[$i]</TD>\n";
}
print "</TR>\n";
}
print "</TABLE>\n";
} else {
echo "No data found<BR>\n";
}
print "$nrows Records Selected<BR>\n";
OCIFreeStatement($stmt);
OCILogoff($conn);
?> |
|