1--TEST-- 2function test: mysqli_num_fields() 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once 'skipifconnectfailure.inc'; 8?> 9--FILE-- 10<?php 11 require_once 'connect.inc'; 12 13 /*** test mysqli_connect 127.0.0.1 ***/ 14 $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); 15 16 mysqli_select_db($link, $db); 17 18 mysqli_query($link, "DROP TABLE IF EXISTS test_result"); 19 20 mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10)) ENGINE = " . $engine); 21 22 mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')"); 23 24 mysqli_real_query($link, "SELECT * FROM test_result"); 25 if (mysqli_field_count($link)) { 26 $result = mysqli_store_result($link); 27 $num = mysqli_num_fields($result); 28 mysqli_free_result($result); 29 } 30 31 var_dump($num); 32 33 mysqli_query($link, "DROP TABLE IF EXISTS test_result"); 34 mysqli_close($link); 35?> 36--CLEAN-- 37<?php 38require_once 'connect.inc'; 39if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 40 printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 41 42if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result")) 43 printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 44 45mysqli_close($link); 46?> 47--EXPECT-- 48int(2) 49