It looks like passing 0 (zero) as a $maxrows parameter is treated identically as -1 value - all the rows are returned.
OCIfetchstatement($stmt, $res, 1, 0, OCI_FETCHSTATEMENT_BY_ROW)
Tested under: PHP 4.4.3, WinXP pro
oci_fetch_all
(PHP 5, PECL oci8:1.1-1.2.4)
oci_fetch_all — Выбирает все строки из результата запроса в массив
Описание
oci_fetch_all() выбирает все строки из результата запроса в указанный пользователем массив. oci_fetch_all() возвращает количество выбранных строк или FALSE в случае ошибки. Параметр skip указывает количество строк с начала резульата, которые следует пропустить (по умолчанию этот параметр равен 0, т.е. обработка начинается с самого начала). Параметр maxrows - это количество строк, которое требуется прочесть, начиная со строки, указанной в параметре\ skip (по умолчанию равно -1, т.е. все строки).
Аргумент flags может быть комбинацией следующих флагов:
- OCI_FETCHSTATEMENT_BY_ROW
- OCI_FETCHSTATEMENT_BY_COLUMN (значение по умолчанию)
- OCI_NUM
- OCI_ASSOC
Пример #1 Пример использования oci_fetch_all()
<?php
/* oci_fetch_all example mbritton at verinet dot com (990624) */
$conn = oci_connect("scott", "tiger");
$stmt = oci_parse($conn, "select * from emp");
oci_execute($stmt);
$nrows = oci_fetch_all($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";
oci_free_statement($stmt);
oci_close($conn);
?>
oci_fetch_all() возвращает FALSE в случае ошибки.
Замечание: В версиях PHP ниже 5.0.0 эта функция называлась ocifetchstatement(). В PHP 5.0.0 и выше ocifetchstatement() является алиасом oci_fetch_all(), поэтому вы можете продолжать использовать это имя, однако это не рекомендуется.
oci_fetch_all
11-Jul-2007 02:55
07-Feb-2007 04:43
If you want to use more than one flag, you need to use the + to connect them:
<?php
oci_fetch_all($stmt, $row, "0", "-1", OCI_ASSOC+OCI_FETCHSTATEMENT_BY_ROW);
?>
12-Feb-2006 11:46
The number of rows returned is the number actually fetched, not the number potentially available. If one limits the number of rows to fetch, the number of rows returned will be bound by that limit. For example...
$nrows = oci_fetch_all($statement, $results, 0, 1);
would result in a returned value of '0' if there are no rows found for the statement, or '1' if any rows were found, regardless of the number actually present in the database.
