1--TEST-- 2mysqli_next_result() 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifconnectfailure.inc'); 7?> 8--FILE-- 9<?php 10 require_once("connect.inc"); 11 12 require('table.inc'); 13 14 if (false !== ($tmp = mysqli_next_result($link))) 15 printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); 16 17 $res = mysqli_query($link, "SELECT 1 AS res"); 18 if (false !== ($tmp = mysqli_next_result($link))) 19 printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); 20 21 mysqli_free_result($res); 22 23 function func_test_mysqli_next_result($link, $query, $offset, $num_results) { 24 25 if (!mysqli_multi_query($link, $query)) 26 printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); 27 28 $i = 0; 29 do { 30 if ($res = mysqli_store_result($link)) { 31 mysqli_free_result($res); 32 $i++; 33 } 34 } while (true === mysqli_next_result($link)); 35 36 if ($i !== $num_results) { 37 printf("[%03d] Expecting %d result(s), got %d result(s)\n", $offset + 2, $num_results, $i); 38 } 39 40 if (mysqli_more_results($link)) 41 printf("[%03d] mysqli_more_results() indicates more results than expected\n", $offset + 3); 42 43 if (!($res = mysqli_query($link, "SELECT 1 AS b"))) { 44 printf("[%03d] [%d] %s\n", $offset + 4, mysqli_errno($link), mysqli_error($link)); 45 } else { 46 mysqli_free_result($res); 47 } 48 49 } 50 51 func_test_mysqli_next_result($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3", 5, 3); 52 func_test_mysqli_next_result($link, "SELECT 1 AS a; INSERT INTO test(id, label) VALUES (100, 'y'); SELECT 1 AS a, 2 AS b", 8, 2); 53 func_test_mysqli_next_result($link, "DELETE FROM test WHERE id >= 100; SELECT 1 AS a; ", 11, 1); 54 55 mysqli_close($link); 56 57 try { 58 mysqli_next_result($link); 59 } catch (Error $exception) { 60 echo $exception->getMessage() . "\n"; 61 } 62 63 print "done!"; 64?> 65--CLEAN-- 66<?php 67 require_once("clean_table.inc"); 68?> 69--EXPECT-- 70mysqli object is already closed 71done! 72