
mysqli_result::fetch_field_direct 함수는 mysqli_result 객체에서 특정 필드의 정보를 가져올 때 사용됩니다. 이 함수는 mysqli_result 객체에서 필드의 인덱스를 지정하여 필드의 정보를 가져올 수 있습니다.
이 함수는 특정 필드의 정보를 가져올 때 사용됩니다. 예를 들어, SELECT 문에서 여러 필드를 선택했을 때, 특정 필드의 정보를 가져올 때 사용할 수 있습니다.
이 함수의 사용법은 다음과 같습니다.
- mysqli_result::fetch_field_direct($field_index)
$field_index는 필드의 인덱스를 지정하는 변수입니다. 필드의 인덱스는 0부터 시작합니다.
예를 들어, SELECT 문에서 id, name, age 필드를 선택했을 때, id 필드의 정보를 가져올 수 있습니다.
#hostingforum.kr
php
$result = mysqli_query($conn, "SELECT id, name, age FROM users");
$field = $result->fetch_field_direct(0);
echo $field->name; // id
echo $field->orgname; // id
echo $field->table; // users
echo $field->def; // NULL
echo $field->max_length; // 11
echo $field->name; // id
echo $field->type; // 4
echo $field->flags; // 0
echo $field->dec; // NULL
echo $field->len; // 11
echo $field->precision; // NULL
이 함수는 필드의 정보를 가져올 때 사용됩니다. 필드의 정보를 가져올 때 사용하는 필드 인덱스는 0부터 시작합니다.
2025-03-06 20:13