PHP Manual
后退 |  | 前进

# ocifetchstatement

(PHP 3 >= 3.0.8, PHP 4, PHP 5)

ocifetchstatement -- »ñÈ¡½á¹ûÊý¾ÝµÄËùÓÐÐÐµ½Ò»¸öÊý×é

## ÃèÊö

int ocifetchstatement ( resource stmt, array &output [, int skip [, int maxrows [, int flags]]] )

ocifetchstatement() ´ÓÒ»¸ö½á¹ûÖÐ»ñÈ¡ËùÓÐµÄÐÐµ½Ò»¸ö ÓÃ»§¶¨ÒåµÄÊý×é¡£ ocifetchstatement() ·µ»Ø»ñÈ¡µÄÐÐÊý¡£ skip ÊÇ´Ó½á¹ûÖÐ»ñÈ¡Êý¾ÝÊ±£¬×î¿ªÊ¼ºöÂÔµÄÐÐÊý (¸Ã²ÎÊýµÄÄ¬ÈÏÖµÊÇ 0£¬¼´´ÓµÚÒ»ÐÐ¿ªÊ¼)¡£ maxrows ÊÇ¶ÁÈ¡µÄÐÐÊý£¬´ÓµÚ skip ÐÐ¿ªÊ¼ (Ä¬ÈÏÖµÊÇ -1£¬¼´ËùÓÐÐÐ)¡£

flags ±íÊ¾´æÔÚµÄÑ¡Ïî£¬ ¿ÉÒÔÊÇÏÂÁÐÈÎÒ»µÄ×éºÏ£º

`OCI_FETCHSTATEMENT_BY_ROW`
`OCI_FETCHSTATEMENT_BY_COLUMN` (Ä¬ÈÏÖµ)
`OCI_NUM`
`OCI_ASSOC`

例子 1. ocifetchstatement()

`<?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);
?>`

后退 | 起点 | 前进
ocifetchinto | 上一级 | ocifreecollection