1--TEST-- 2mysqli_stmt_errno() 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once 'skipifconnectfailure.inc'; 8?> 9--FILE-- 10<?php 11 require 'table.inc'; 12 13 if (!$stmt = mysqli_stmt_init($link)) 14 printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 15 16 // properly initialized? 17 if (0 !== ($tmp = mysqli_stmt_errno($stmt))) 18 printf("[004] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); 19 20 if (mysqli_stmt_prepare($stmt, "SELECT i_do_not_exist_believe_me FROM test ORDER BY id")) 21 printf("[005] Statement should have failed!\n"); 22 23 // set after error server? 24 if (0 === ($tmp = mysqli_stmt_errno($stmt))) 25 printf("[006] Expecting int/any non zero, got %s/%s\n", gettype($tmp), $tmp); 26 27 if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id")) 28 printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 29 30 // reset after error & success 31 if (0 != ($tmp = mysqli_stmt_errno($stmt))) 32 printf("[008] Expecting zero, got %s/%s\n", gettype($tmp), $tmp); 33 34 $link->query('KILL '.mysqli_thread_id($link)); 35 36 if (true === ($tmp = mysqli_stmt_execute($stmt))) 37 printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); 38 39 // set after client error 40 if (0 === ($tmp = mysqli_stmt_errno($stmt))) 41 printf("[010] Expecting int/any non zero, got %s/%s\n", gettype($tmp), $tmp); 42 43 mysqli_stmt_close($stmt); 44 45 try { 46 mysqli_stmt_errno($stmt); 47 } catch (Error $exception) { 48 echo $exception->getMessage() . "\n"; 49 } 50 51 mysqli_close($link); 52 print "done!"; 53?> 54--CLEAN-- 55<?php 56 require_once 'clean_table.inc'; 57?> 58--EXPECT-- 59mysqli_stmt object is already closed 60done! 61