mysqli_result::$field_count

(PHP 5, PHP 7, PHP 8)

mysqli_result::$field_count -- mysqli_num_fields — 결과 세트의 필드 수를 가져옵니다.


설명

객체 지향 스타일

int $mysqli_result->field_count;

절차적 스타일

mysqli_num_fields(mysqli_result $result): int

결과 집합의 필드 수를 반환합니다.


매개변수

result
절차적 스타일 전용: mysqli_query(), mysqli_store_result(), mysqli_use_result() 또는 mysqli_stmt_get_result()에 의해 반환된 mysqli_result 객체.

반환 값

필드 수를 나타내는 int입니다.


Examples

예제 #1 객체 지향 스타일

                  
<?php

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");

$result = $mysqli->query("SELECT Name, CountryCode, District, Population FROM City ORDER BY ID LIMIT 1");

/* Get the number of fields in the result set */
$field_cnt = $result->field_count;

printf("Result set has %d fields.\n", $field_cnt);
                  
                

예제 #2 >절차적 스타일

                  
<?php

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$link = mysqli_connect("localhost", "my_user", "my_password", "world");

$result = mysqli_query($link, "SELECT Name, CountryCode, District, Population FROM City ORDER BY ID LIMIT 1");

/* Get the number of fields in the result set */
$field_cnt = mysqli_num_fields($result);

printf("Result set has %d fields.\n", $field_cnt);
                  
                

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

Result set has 4 fields.
                

기타