1--TEST-- 2mysqli_stmt_execute() - OUT 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/* 16if ($IS_MYSQLND) { 17 die(sprintf("skip WHY ?!")); 18} 19*/ 20?> 21--FILE-- 22<?php 23 require_once('connect.inc'); 24 25 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { 26 printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", 27 $host, $user, $db, $port, $socket); 28 } 29 30 if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p')) 31 printf("[003] [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); 32 33 if (mysqli_real_query($link, 'CREATE PROCEDURE p(IN ver_in VARCHAR(25), OUT ver_out VARCHAR(25)) BEGIN SELECT ver_in INTO ver_out; END;')) { 34 if (!$stmt = mysqli_prepare($link, 'CALL p(?, ?)')) 35 printf("[005] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 36 37 $ver_in = 'myversion'; 38 $ver_out = ''; 39 if (!mysqli_stmt_bind_param($stmt, 'ss', $ver_in, $ver_out)) 40 printf("[006] Cannot bind parameter, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 41 42 if (!mysqli_stmt_execute($stmt)) 43 printf("[007] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 44 45 printf("[008] More results: %s\n", (mysqli_more_results($link) ? "yes" : "no")); 46 printf("[009] Next results: %s\n", (mysqli_next_result($link) ? "yes" : "no")); 47 48 try { 49 if (!mysqli_stmt_bind_result($stmt, $ver_out) || !mysqli_stmt_fetch($stmt)) 50 printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 51 } catch (\ArgumentCountError $e) { 52 echo $e->getMessage() . \PHP_EOL; 53 } 54 55 if ("myversion" !== $ver_out) 56 printf("[011] Results seem wrong got '%s'\n", $ver_out); 57 58 if (!mysqli_stmt_close($stmt)) 59 printf("[012] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 60 61 if (!$res = $link->query("SELECT 1")) 62 printf("[013] [%d] %s\n", $link->errno, $link->error); 63 64 } else { 65 printf("[004] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); 66 } 67 68 mysqli_close($link); 69 print "done!"; 70?> 71--CLEAN-- 72<?php 73require_once("connect.inc"); 74if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 75 printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 76 77@mysqli_query($link, 'DROP PROCEDURE IF EXISTS p'); 78 79mysqli_close($link); 80?> 81--XFAIL-- 82Unsupported and undefined, under development 83--EXPECTF-- 84[008] More results: %s 85[009] Next results: %s 86done! 87