1--TEST-- 2mysqli_stmt_execute() - SP, next result 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once('skipifconnectfailure.inc'); 8require_once('connect.inc'); 9if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { 10 die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error())); 11} 12if (mysqli_get_server_version($link) < 50503) { 13 die(sprintf('skip Needs MySQL 5.5.3+, found version %d.', mysqli_get_server_version($link))); 14} 15?> 16--FILE-- 17<?php 18 require_once('connect.inc'); 19 20 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { 21 printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", 22 $host, $user, $db, $port, $socket); 23 } 24 25 if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p')) 26 printf("[003] [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); 27 28 if (mysqli_real_query($link, 'CREATE PROCEDURE p(IN ver_in VARCHAR(25)) BEGIN SELECT ver_in AS _ver_out; END;')) { 29 // one result set 30 if (!$stmt = mysqli_prepare($link, 'CALL p(?)')) 31 printf("[005] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 32 33 $version = 'myversion'; 34 if (!mysqli_stmt_bind_param($stmt, 's', $version)) 35 printf("[006] Cannot bind input parameter, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 36 37 if (!mysqli_stmt_execute($stmt)) 38 printf("[007] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 39 40 $version = 'unknown'; 41 if (!mysqli_stmt_bind_result($stmt, $version) || 42 !mysqli_stmt_fetch($stmt)) 43 printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 44 45 if ($version !== "myversion") 46 printf("[009] Results seem wrong, got %s, [%d] %s\n", 47 $version, 48 mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 49 50 mysqli_stmt_free_result($stmt); 51 52 printf("[010] More results: %s\n", (mysqli_more_results($link)) ? "yes" : "no"); 53 printf("[011] Next result: %s\n", (mysqli_next_result($link)) ? "yes" : "no"); 54 55 if (!mysqli_stmt_close($stmt)) 56 printf("[012] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 57 58 if (!$link->query("SELECT 1")) 59 printf("[013] [%d] %s\n", $link->errno, $link->error); 60 61 } else { 62 printf("[004] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); 63 } 64 65 if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p')) 66 printf("[014] [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); 67 68 if (mysqli_real_query($link, 'CREATE PROCEDURE p(IN ver_in VARCHAR(25)) BEGIN SELECT ver_in AS _ver_out; SELECT 1 AS _more; END;')) { 69 // two result sets 70 if (!$stmt = mysqli_prepare($link, 'CALL p(?)')) 71 printf("[015] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 72 73 $version = 'myversion'; 74 if (!mysqli_stmt_bind_param($stmt, 's', $version)) 75 printf("[016] Cannot bind input parameter, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 76 77 if (!mysqli_stmt_execute($stmt)) 78 printf("[017] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 79 80 $version = NULL; 81 if (!mysqli_stmt_bind_result($stmt, $version) || 82 !mysqli_stmt_fetch($stmt)) 83 printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 84 85 if ($version !== "myversion") 86 printf("[019] Results seem wrong, got %s, [%d] %s\n", 87 $version, 88 mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 89 90 if (!mysqli_more_results($link) || !mysqli_next_result($link)) 91 printf("[020] [%d] %s\n", $link->errno, $link->error); 92 93 $more = NULL; 94 if (!mysqli_stmt_bind_result($stmt, $more) || 95 !mysqli_stmt_fetch($stmt)) 96 printf("[021] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 97 98 if ($more !== 1) 99 printf("[022] Results seem wrong, got %s, [%d] %s\n", 100 $more, 101 mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 102 103 if (!mysqli_stmt_close($stmt)) 104 printf("[023] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 105 106 107 if (!$link->query("SELECT 1")) 108 printf("[024] [%d] %s\n", $link->errno, $link->error); 109 110 } else { 111 printf("[025] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); 112 } 113 114 mysqli_close($link); 115 print "done!"; 116?> 117--CLEAN-- 118<?php 119require_once("connect.inc"); 120if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 121 printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 122 123@mysqli_query($link, 'DROP PROCEDURE IF EXISTS p'); 124 125mysqli_close($link); 126?> 127--XFAIL-- 128Unsupported and undefined, under development 129--EXPECT-- 130[010] More results: yes 131[011] Next result: yes 132done! 133