1--TEST-- 2mysqli_stmt_close() 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once('skipifconnectfailure.inc'); 8?> 9--FILE-- 10<?php 11 require_once("connect.inc"); 12 13 require('table.inc'); 14 15 if (!$stmt = mysqli_stmt_init($link)) 16 printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 17 18 // Yes, amazing, eh? AFAIK a work around of a constructor bug... 19 try { 20 mysqli_stmt_close($stmt); 21 } catch (Error $exception) { 22 echo $exception->getMessage() . "\n"; 23 } 24 25 if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) 26 printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 27 28 if (true !== ($tmp = mysqli_stmt_close($stmt))) 29 printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); 30 31 try { 32 mysqli_stmt_close($stmt); 33 } catch (Error $exception) { 34 echo $exception->getMessage() . "\n"; 35 } 36 37 if (!$stmt = mysqli_stmt_init($link)) 38 printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 39 40 if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) 41 printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 42 43 $id = $label = null; 44 if (!mysqli_stmt_bind_param($stmt, "is", $id, $label)) 45 printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 46 47 $id = 100; $label = 'z'; 48 if (!mysqli_stmt_execute($stmt)) 49 printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 50 51 mysqli_kill($link, mysqli_thread_id($link)); 52 53 if (true !== ($tmp = mysqli_stmt_close($stmt))) 54 printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); 55 56 mysqli_close($link); 57 58 require('table.inc'); 59 if (!$stmt = mysqli_stmt_init($link)) 60 printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 61 62 if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) 63 printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 64 65 $id = $label = null; 66 if (!mysqli_stmt_bind_result($stmt, $id, $label)) 67 printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 68 69 if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) 70 printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 71 72 mysqli_kill($link, mysqli_thread_id($link)); 73 74 if (true !== ($tmp = mysqli_stmt_close($stmt))) 75 printf("[017] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); 76 77 print "done!"; 78?> 79--CLEAN-- 80<?php 81 require_once("clean_table.inc"); 82?> 83--EXPECT-- 84mysqli_stmt object is not fully initialized 85mysqli_stmt object is already closed 86done! 87