Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: oci_fetch_all - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

oci_fetch_array" width="11" height="7"/> <oci_execute
Last updated: Thu, 31 May 2007

view this page in

oci_fetch_all

(PHP 5, PECL oci8:1.1-1.2.3)

oci_fetch_all — 結果データの全ての行を配列に取得する

説明

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

全ての行の結果をユーザー定義の配列に格納して取得します。

oci8 ドライバによるデータ型マッピングの 詳細については、ドライバが サポートするデータ型 を参照ください。

パラメータ

statement

有効な OCI ステートメント ID。

output

注意: この関数は、 NULL フィールドに PHPの NULL 値を設定します。

skip

結果を取得する際に無視する行数 (デフォルトの値は 0 で、最初の行から開始されます) 。

maxrows

読み込む行数。 skip 番目の行から開始されます (デフォルトは -1 で、全ての行 を意味します)。

flags

パラメータ flags には次の値の組み合わせが可能です。

OCI_FETCHSTATEMENT_BY_ROW
OCI_FETCHSTATEMENT_BY_COLUMN (デフォルト値)
OCI_NUM
OCI_ASSOC

返り値

取得した行数、失敗した場合 FALSE を返します。

例 1593. oci_fetch_all() の例

<?php
/* oci_fetch_all の例 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";
   foreach (
$results as $key => $val) {
      echo
"<th>$key</th>\n";
   }
   echo
"</tr>\n";

   for (
$i = 0; $i < $nrows; $i++) {
      echo
"<tr>\n";
      foreach (
$results as $data) {
         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);
?>

注意

注意: PHP バージョン 5.0.0 以前では、代わりに ocifetchstatement() を使用しなければなりません。 まだこの名前を使用することができ、下位互換性のため oci_fetch_all() への別名として残されていますが、 推奨されません。



oci_fetch_array" width="11" height="7"/> <oci_execute
Last updated: Thu, 31 May 2007
 
add a note add a note User Contributed Notes
oci_fetch_all
dawid.krysiak.net.pl
11-Jul-2007 09: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
08-Feb-2007 12: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
13-Feb-2006 07: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" width="11" height="7"/> <oci_execute
Last updated: Thu, 31 May 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites