db2_fetch_row

(no version information, might be only in CVS)

db2_fetch_row --  Sets the result set pointer to the next row or requested row

説明

bool db2_fetch_row ( resource stmt [, int row_number] )

警告

この関数は、 実験的なステータスにあります。これは、この関数の 動作、関数名、ここで書かれていること全てがPHPの将来のバージョンで予告 なく変更される可能性があることを意味します。注意を喚起するとともに自分 のリスクでこの関数を使用してください。

Use db2_fetch_row() to iterate through a result set, or to point to a specific row in a result set if you requested a scrollable cursor.

To retrieve individual fields from the result set, call the db2_result() function.

Rather than calling db2_fetch_row() and db2_result(), most applications will call one of db2_fetch_assoc(), db2_fetch_both(), or db2_fetch_array() to advance the result set pointer and return a complete row as an array.

パラメータ

stmt

A valid stmt resource.

row_number

With scrollable cursors, you can request a specific row number in the result set. Row numbering is 1-indexed.

戻り値

Returns TRUE if the requested row exists in the result set. Returns FALSE if the requested row does not exist in the result set.

例 1. Iterating through a result set

The following example demonstrates how to iterate through a result set with db2_fetch_row() and retrieve columns from the result set with db2_result().

<?php
$sql
= 'SELECT name, breed FROM animals WHERE weight < ?';
$stmt = db2_prepare($conn, $sql);
db2_execute($stmt, array(10));
while (
db2_fetch_row($stmt)) {
    
$name = db2_result($stmt, 0);
    
$breed = db2_result($stmt, 1);
    print
"$name $breed";
}
?>

上の例の出力は以下となります:

cat Pook
gold fish Bubbles
budgerigar Gizmo
goat Rickety Ride

以下も参照ください

db2_fetch_array()
db2_fetch_assoc()
db2_fetch_both()
db2_fetch_object()
db2_result()