1--TEST-- 2mysqli_num_fields() 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once 'skipifconnectfailure.inc'; 8?> 9--FILE-- 10<?php 11 require 'table.inc'; 12 13 function func_test_mysqli_num_fields(mysqli $link, string $query, int $expected, int $offset) { 14 15 if (!($res = mysqli_query($link, $query))) { 16 printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); 17 return; 18 } 19 20 if ($expected !== ($tmp = mysqli_num_fields($res))) 21 printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 1, 22 gettype($expected), $expected, 23 gettype($tmp), $tmp); 24 25 mysqli_free_result($res); 26 27 try { 28 mysqli_num_fields($res); 29 } catch (Error $exception) { 30 echo $exception->getMessage() . "\n"; 31 } 32 } 33 34 func_test_mysqli_num_fields($link, "SELECT 1 AS a", 1, 5); 35 func_test_mysqli_num_fields($link, "SELECT id, label FROM test", 2, 10); 36 func_test_mysqli_num_fields($link, "SELECT 1 AS a, NULL AS b, 'foo' AS c", 3, 15); 37 func_test_mysqli_num_fields($link, "SELECT id FROM test", 1, 20); 38 39 mysqli_close($link); 40 41 print "done!"; 42?> 43--CLEAN-- 44<?php 45 require_once 'clean_table.inc'; 46?> 47--EXPECT-- 48mysqli_result object is already closed 49mysqli_result object is already closed 50mysqli_result object is already closed 51mysqli_result object is already closed 52done! 53