(PHP 5)
mysqli_stmt::data_seek -- mysqli_stmt_data_seek — ステートメントの結果セットの任意の行に移動する
オブジェクト指向型(メソッド):
手続き型:
ステートメントの結果セット内で、 任意の位置に結果ポインタを移動します。
手続き型のみ: mysqli_stmt_init() が返すステートメント ID。
ゼロから行の総数 - 1(0..mysqli_stmt_num_rows() - 1) までの間である必要があります。
値を返しません。
例1 オブジェクト指向型
<?php
/* 接続をオープンします */
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* 接続状況をチェックします */ 
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}
$query = "SELECT Name, CountryCode FROM City ORDER BY Name";
if ($stmt = $mysqli->prepare($query)) {
    /* クエリを実行します */
    $stmt->execute();
    /* 結果変数をバインドします */
    $stmt->bind_result($name, $code);
    /* 結果を取得します */
    $stmt->store_result();
    /* 行番号 400 に移動します */
    $stmt->data_seek(399);
    /* 値を取得します */
    $stmt->fetch();
    printf ("City: %s  Countrycode: %s\n", $name, $code);
    /* ステートメントを閉じます */
    $stmt->close();
}
/* 接続を閉じます */
$mysqli->close();
?>
例2 手続き型
<?php
/* 接続をオープンします */
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* 接続状況をチェックします */ 
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}
$query = "SELECT Name, CountryCode FROM City ORDER BY Name";
if ($stmt = mysqli_prepare($link, $query)) {
    /* クエリを実行します */
    mysqli_stmt_execute($stmt);
    /* 結果変数をバインドします */
    mysqli_stmt_bind_result($stmt, $name, $code);
    /* 結果を取得します */
    mysqli_stmt_store_result($stmt);
    /* 行番号 400 に移動します */
    mysqli_stmt_data_seek($stmt, 399);
    /* 値を取得します */
    mysqli_stmt_fetch($stmt);
    printf ("City: %s  Countrycode: %s\n", $name, $code);
    /* ステートメントを閉じます */
    mysqli_stmt_close($stmt);
}
/* 接続を閉じます */
mysqli_close($link);
?>
上の例の出力は以下となります。
City: Benin City Countrycode: NGA
NPO法人の設立(東京・大阪) 東京や大阪などNPO法人を設立する場合の注意点等を紹介
不動産・賃貸・マンション 不動産・賃貸・マンションに関する用語集です。
堺市の入院・内科大阪の賃貸探し 大阪で賃貸を探している方は大阪ホームへ
東京の賃貸マンション 東京で賃貸を探すなら東京賃貸.orgへ