Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

oci_fetch_all

(PHP 5)

oci_fetch_all -- Выбирает все строки из результата запроса в массив

Описание

int oci_fetch_all ( resource statement, array &output [, int skip [, int maxrows [, int flags]]] )

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_array> <oci_execute
Last updated: Sat, 27 Jan 2007
 
add a note add a note User Contributed Notes
oci_fetch_all
dawid.krysiak.net.pl
11-Jul-2007 05:55
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
stry_cat at yahoo dot com
07-Feb-2007 07: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);

?>
jnavratil at houston dot rr dot com
12-Feb-2006 02: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.

oci_fetch_array> <oci_execute
Last updated: Sat, 27 Jan 2007
 
 
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571