(PHP 5)
mysqli_result::field_seek -- mysqli_field_seek — 結果ポインタを、指定したフィールドオフセットに設定する
オブジェクト指向型
手続き型
フィールドカーソルを指定したオフセットに設定します。 mysqli_fetch_field() を次にコールした際に、 設定したオフセットに関連するカラムのフィールド定義を取得します。
注意:
行のはじめに移動するには、オフセットとしてゼロを指定します。
手続き型のみ: mysqli_query()、mysqli_store_result() あるいは mysqli_use_result() が返す結果セット ID。
フィールド番号。これは 0 から フィールド数 - 1 までの範囲でなければなりません。
成功した場合に TRUE を、失敗した場合に FALSE を返します。
オブジェクト指向型
<?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, SurfaceArea from Country ORDER BY Code LIMIT 5";
if ($result = $mysqli->query($query)) {
    /* 2 番目のカラムのフィールド情報を取得します */
    $result->field_seek(1);
    $finfo = $result->fetch_field();
    printf("Name:     %s\n", $finfo->name);
    printf("Table:    %s\n", $finfo->table);
    printf("max. Len: %d\n", $finfo->max_length);
    printf("Flags:    %d\n", $finfo->flags);
    printf("Type:     %d\n\n", $finfo->type);
    $result->close();
}
/* 接続を閉じます */
$mysqli->close();
?>
手続き型
<?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, SurfaceArea from Country ORDER BY Code LIMIT 5";
if ($result = mysqli_query($link, $query)) {
    /* 2 番目のカラムのフィールド情報を取得します */
    mysqli_field_seek($result, 1);
    $finfo = mysqli_fetch_field($result);
    printf("Name:     %s\n", $finfo->name);
    printf("Table:    %s\n", $finfo->table);
    printf("max. Len: %d\n", $finfo->max_length);
    printf("Flags:    %d\n", $finfo->flags);
    printf("Type:     %d\n\n", $finfo->type);
    mysqli_free_result($result);
}
/* 接続を閉じます */
mysqli_close($link);
?>
上の例の出力は以下となります。
Name: SurfaceArea Table: Country max. Len: 10 Flags: 32769 Type: 4