mysqli_result::field_seek

(PHP 5, PHP 7, PHP 8)

mysqli_result::field_seek -- mysqli_field_seek — 결과 포인터를 지정된 필드 오프셋으로 설정


설명

객체 지향 스타일

public mysqli_result::field_seek(int $index): bool

절차적 스타일

mysqli_field_seek(mysqli_result $result, int $index): bool

필드 커서를 지정된 오프셋으로 설정합니다. mysqli_fetch_field()에 대한 다음 호출은 해당 오프셋과 관련된 열의 필드 정의를 검색합니다.

메모: 행의 시작 부분을 찾으려면 오프셋 값 0을 전달합니다.


매개변수

result
절차적 스타일 전용: mysqli_query(), mysqli_store_result(), mysqli_use_result() 또는 mysqli_stmt_get_result()에 의해 반환된 mysqli_result 객체.
index
필드 번호입니다. 이 값은 0에서 number of fields - 1 사이여야 합니다.

반환 값

성공하면 true를, 실패하면 false를 반환합니다.


Examples

예제 #1 객체 지향 스타일

                  
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");

/* check connection */
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)) {

    /* Get field information for 2nd column */
    $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();
}

/* close connection */
$mysqli->close();
?>
                  
                

예제 #2 절차적 스타일

                  
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");

/* check connection */
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)) {

    /* Get field information for 2nd column */
    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);
}

/* close connection */
mysqli_close($link);
?>
                  
                

위의 예는 다음을 출력합니다.

Name:     SurfaceArea
Table:    Country
max. Len: 10
Flags:    32769
Type:     4
                

기타