현재 위치: > 함수 카테고리 모음> mysqli_result::$field_count

mysqli_result::$field_count

(mysqli_num_fields) 결과에서 필드 수를 얻습니다
이름:mysqli_result::$field_count
분류:mysqli
사용 언어:php
한 줄 설명:결과 세트의 필드 수를 반환합니다

mysqli_result :: $ field_count () 함수는 결과 세트의 필드 수를 반환합니다.

용법:

 int mysqli_result::$field_count ( void )

예:

 // 连接到数据库$mysqli = new mysqli("localhost", "username", "password", "database"); if ($mysqli->connect_errno) { die("连接失败: " . $mysqli->connect_error); } // 执行查询语句$result = $mysqli->query("SELECT * FROM table"); // 获取结果集中的字段数量$fieldCount = $result->field_count; echo "结果集中的字段数量为: " . $fieldCount; // 释放结果集和关闭数据库连接$result->free(); $mysqli->close();

위의 예에서는 먼저 MySQLI 클래스를 사용하여 데이터베이스에 연결합니다. 그런 다음 쿼리 명령문을 실행하고 결과를 $ 결과 변수에 저장합니다. 다음으로 mysqli_result :: $ field_count () 함수를 사용하여 결과 세트의 필드 수를 얻고 $ FieldCount 변수에 저장합니다. 마지막으로 필드 수를 출력합니다.

mysqli_result :: $ field_count () 함수를 사용하기 전에 쿼리 문을 실행하고 결과 세트를 가져와야합니다. 동시에, 결과 세트의 사용을 완료 한 후에는 mysqli_result :: free () 메소드를 사용하여 결과 세트를 해제하고 mysqli :: close () 메소드를 사용하여 데이터베이스 연결을 닫아야합니다.

유사한 함수
인기 기사