1--TEST-- 2Multiple result set with PS 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once("connect.inc"); 7if (!$IS_MYSQLND) { 8 die("skip mysqlnd only test"); 9} 10require_once('skipifconnectfailure.inc'); 11?> 12--FILE-- 13<?php 14 require_once("connect.inc"); 15 require('table.inc'); 16 17 $stmt = mysqli_stmt_init($link); 18 if (!$link->query('DROP PROCEDURE IF EXISTS p123')) { 19 printf("[001] [%d] %s\n", $link->error, $link->errno); 20 } 21 22 if (!$link->query("CREATE PROCEDURE p123() BEGIN SELECT id+12, CONCAT_WS('-',label,'ahoi') FROM test ORDER BY id LIMIT 1; SELECT id + 42, CONCAT_WS('---',label, label) FROM test ORDER BY id LIMIT 1; END")) { 23 printf("[002] [%d] %s\n", $link->error, $link->errno); 24 } 25 26 if (!($stmt = $link->prepare("CALL p123"))) { 27 printf("[003] [%d] %s\n", $stmt->error, $stmt->errno); 28 } 29 30 if (!$stmt->execute()) { 31 printf("[005] [%d] %s\n", $stmt->error, $stmt->errno); 32 } 33 34 $c_id = NULL; 35 $c_label = NULL; 36 if (!$stmt->bind_result($c_id, $c_label)) { 37 printf("[004] [%d] %s\n", $stmt->error, $stmt->errno); 38 } 39 var_dump("pre:",$c_id, $c_label); 40 41 if (!$stmt->fetch()) { 42 printf("[006] [%d] %s\n", $stmt->error, $stmt->errno); 43 } 44 45 var_dump("post:",$c_id, $c_label); 46 47 if ($stmt->fetch()) { 48 printf("[007] Shouldn't have fetched anything\n"); 49 var_dump($c_id, $c_label); 50 } 51 52 if ($stmt->fetch()) { 53 printf("[008] No more rows expected\n"); 54 } 55 56 if (!$stmt->more_results()) { 57 printf("[009] Expected more results\n"); 58 } else { 59 var_dump("[009] next_result:", $stmt->next_result()); 60 } 61 62 if (!$stmt->bind_result($c_id, $c_label)) { 63 printf("[010] [%d] %s\n", $stmt->error, $stmt->errno); 64 } 65 var_dump("pre:",$c_id, $c_label); 66 67 if (!$stmt->fetch()) { 68 printf("[011] [%d] %s\n", $stmt->error, $stmt->errno); 69 } 70 71 var_dump("post:",$c_id, $c_label); 72 73 if ($stmt->fetch()) { 74 printf("[012] No more rows expected\n"); 75 } 76 77 if (!$stmt->more_results()) { 78 printf("[013] Expected more results\n"); 79 } else { 80 var_dump("[013] next_result:", $stmt->next_result()); 81 } 82 83 if ($stmt->more_results()) { 84 printf("[014] No more results expected\n"); 85 } else { 86 printf("[014] No result, as expected\n"); 87 } 88 89 $stmt->close(); 90 $link->close(); 91 92 93 echo "done"; 94?> 95--CLEAN-- 96<?php 97 require_once("connect.inc"); 98 if (!$link->query('DROP PROCEDURE IF EXISTS p123')) { 99 printf("[001] [%d] %s\n", $link->error, $link->errno); 100 } 101?> 102--EXPECTF-- 103string(4) "pre:" 104NULL 105NULL 106string(5) "post:" 107int(13) 108string(6) "a-ahoi" 109string(18) "[009] next_result:" 110bool(true) 111string(4) "pre:" 112int(13) 113string(6) "a-ahoi" 114string(5) "post:" 115int(43) 116string(5) "a---a" 117string(18) "[013] next_result:" 118bool(true) 119[014] No result, as expected 120done 121