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