1--TEST-- 2mysqli_stmt_store_result() 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("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 17 18 // stmt object status test 19 try { 20 mysqli_stmt_store_result($stmt); 21 } catch (Error $exception) { 22 echo $exception->getMessage() . "\n"; 23 } 24 25 if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100, 'z')") || 26 !mysqli_stmt_execute($stmt)) 27 printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 28 29 if (true !== ($tmp = @mysqli_stmt_store_result($stmt))) 30 printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); 31 32 if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test ORDER BY id') || 33 !mysqli_stmt_execute($stmt)) 34 printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 35 36 if (!$link_buf = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 37 printf("[009] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 38 39 if (!$stmt_buf = mysqli_stmt_init($link_buf)) 40 printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 41 42 if (!mysqli_stmt_prepare($stmt_buf, "SELECT id, label FROM test ORDER BY id") || 43 !mysqli_stmt_execute($stmt_buf)) 44 printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); 45 46 $id = $label = $id_buf = $label_buf = null; 47 if (!mysqli_stmt_bind_result($stmt, $id, $label)) 48 printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 49 50 if (!mysqli_stmt_bind_result($stmt_buf, $id_buf, $label_buf)) 51 printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); 52 53 while (mysqli_stmt_fetch($stmt)) { 54 if (!mysqli_stmt_fetch($stmt_buf)) { 55 printf("[014] Unbuffered statement indicates more rows than buffered, [%d] %s\n", 56 mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); 57 } 58 if ($id !== $id_buf) 59 printf("[015] unbuffered '%s'/%s, buffered '%s'/%s\n", 60 $id, gettype($id), $id_buf, gettype($id_buf)); 61 if ($label !== $label_buf) 62 printf("[016] unbuffered '%s'/%s, buffered '%s'/%s\n", 63 $label, gettype($label), $label_buf, gettype($label_buf)); 64 } 65 66 mysqli_stmt_close($stmt); 67 mysqli_stmt_close($stmt_buf); 68 69 try { 70 mysqli_stmt_store_result($stmt); 71 } catch (Error $exception) { 72 echo $exception->getMessage() . "\n"; 73 } 74 75 mysqli_close($link); 76 mysqli_close($link_buf); 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