1--TEST-- 2$res->fetch_field_direct(s) 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once 'skipifconnectfailure.inc'; 8?> 9--FILE-- 10<?php 11 require 'table.inc'; 12 $mysqli = $link; 13 14 if (!$res = $mysqli->query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) { 15 printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 16 } 17 18 try { 19 var_dump($res->fetch_field_direct(-1)); 20 } catch (\ValueError $e) { 21 echo $e->getMessage() . \PHP_EOL; 22 } 23 24 var_dump($res->fetch_field_direct(0)); 25 26 try { 27 var_dump($res->fetch_field_direct(2)); 28 } catch (\ValueError $e) { 29 echo $e->getMessage() . \PHP_EOL; 30 } 31 32 $res->free_result(); 33 34 try { 35 $res->fetch_field_direct(0); 36 } catch (Error $exception) { 37 echo $exception->getMessage() . "\n"; 38 } 39 40 $mysqli->close(); 41 print "done!"; 42?> 43--CLEAN-- 44<?php 45 require_once 'clean_table.inc'; 46?> 47--EXPECTF-- 48mysqli_result::fetch_field_direct(): Argument #1 ($index) must be greater than or equal to 0 49object(stdClass)#%d (13) { 50 ["name"]=> 51 string(2) "ID" 52 ["orgname"]=> 53 string(2) "id" 54 ["table"]=> 55 string(4) "TEST" 56 ["orgtable"]=> 57 string(%d) "%s" 58 ["def"]=> 59 string(0) "" 60 ["db"]=> 61 string(%d) "%s" 62 ["catalog"]=> 63 string(%d) "%s" 64 ["max_length"]=> 65 int(%d) 66 ["length"]=> 67 int(11) 68 ["charsetnr"]=> 69 int(%d) 70 ["flags"]=> 71 int(%d) 72 ["type"]=> 73 int(%d) 74 ["decimals"]=> 75 int(%d) 76} 77mysqli_result::fetch_field_direct(): Argument #1 ($index) must be less than the number of fields for this result set 78mysqli_result object is already closed 79done! 80