1--TEST-- 2mysqli_stmt_reset() 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifconnectfailure.inc'); 7?> 8--FILE-- 9<?php 10 require_once("connect.inc"); 11 12 // Note: No SQL tests here! We can expand one of the *fetch() 13 // tests to a generic SQL test, if we ever need that. 14 // We would duplicate the SQL test cases if we have it here and in one of the 15 // fetch tests, because the fetch tests would have to call prepare/execute etc. 16 // anyway. 17 18 require('table.inc'); 19 20 if (!$stmt = mysqli_stmt_init($link)) 21 printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 22 23 try { 24 mysqli_stmt_reset($stmt); 25 } catch (Error $exception) { 26 echo $exception->getMessage() . "\n"; 27 } 28 29 if (true !== ($tmp = mysqli_stmt_prepare($stmt, 'SELECT id FROM test'))) 30 printf("[005] Expecting boolean/true, got %s/%s, [%d] %s\n", 31 gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 32 33 if (true !== ($tmp = mysqli_stmt_reset($stmt))) 34 printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); 35 36 if (true !== ($tmp = mysqli_stmt_execute($stmt))) 37 printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); 38 39 $id = null; 40 if (!mysqli_stmt_bind_result($stmt, $id)) 41 printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 42 43 if (!mysqli_stmt_fetch($stmt)) 44 printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 45 46 var_dump($id); 47 mysqli_stmt_close($stmt); 48 if (!$stmt = mysqli_stmt_init($link)) 49 printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 50 51 if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) 52 printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 53 54 if (!mysqli_query($link, "CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT, label BLOB, PRIMARY KEY(id))")) 55 printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 56 57 if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(label) VALUES (?)")) 58 printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 59 60 $label = null; 61 if (!mysqli_stmt_bind_param($stmt, "b", $label)) 62 printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 63 64 $label = 'abc'; 65 for ($i = 0; $i < 10; $i++) { 66 if (!mysqli_stmt_send_long_data($stmt, 0, $label)) 67 printf("[015 - %d] [%d] %s\n", $i, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 68 } 69 70 if (!mysqli_stmt_reset($stmt)) 71 printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 72 73 if (!mysqli_stmt_execute($stmt)) 74 printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 75 76 if (!$res = mysqli_query($link, "SELECT label FROM test")) 77 printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 78 79 if (!$row = mysqli_fetch_assoc($res)) 80 printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 81 82 mysqli_free_result($res); 83 84 if ($row['label'] != '') 85 printf("[020] Expecting empty string, got string/%s\n", $row['label']); 86 87 mysqli_stmt_close($stmt); 88 89 try { 90 mysqli_stmt_reset($stmt); 91 } catch (Error $exception) { 92 echo $exception->getMessage() . "\n"; 93 } 94 95 mysqli_close($link); 96 print "done!"; 97?> 98--CLEAN-- 99<?php 100 require_once("clean_table.inc"); 101?> 102--EXPECT-- 103mysqli_stmt object is not fully initialized 104int(1) 105mysqli_stmt object is already closed 106done! 107