Annotation of embedaddon/php/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: mysqli_stmt_execute() - Stored Procedures
! 3: --SKIPIF--
! 4: <?php
! 5: require_once('skipif.inc');
! 6: require_once('skipifconnectfailure.inc');
! 7: require_once('connect.inc');
! 8: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
! 9: die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
! 10: }
! 11: if (mysqli_get_server_version($link) <= 50000) {
! 12: die(sprintf('skip Needs MySQL 5.0+, found version %d.', mysqli_get_server_version($link)));
! 13: }
! 14: ?>
! 15: --FILE--
! 16: <?php
! 17: require_once('connect.inc');
! 18: require_once('table.inc');
! 19:
! 20: if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p'))
! 21: printf("[009] [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
! 22:
! 23: if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;')) {
! 24: /* no result set, one output parameter */
! 25: if (!$stmt = mysqli_prepare($link, 'CALL p(@version)'))
! 26: printf("[011] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 27:
! 28: if (!mysqli_stmt_execute($stmt))
! 29: printf("[012] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 30:
! 31: /* yes, I really want to call it twice! */
! 32: if (!mysqli_stmt_execute($stmt))
! 33: printf("[013] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 34:
! 35: if (!mysqli_stmt_close($stmt))
! 36: printf("[014] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 37:
! 38: if (!$stmt = mysqli_prepare($link, 'SELECT @version AS _version'))
! 39: printf("[015] Cannot prepare SELECT, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 40:
! 41: if (!mysqli_stmt_execute($stmt))
! 42: printf("[016] Cannot execute SELECT, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 43:
! 44: $version = 'unknown';
! 45: if (!mysqli_stmt_bind_result($stmt, $version) ||
! 46: !mysqli_stmt_fetch($stmt))
! 47: printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 48:
! 49: if (($version == "unknown") || ($version == ""))
! 50: printf("[018] Results seem wrong, got %s, [%d] %s\n",
! 51: $version,
! 52: mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 53:
! 54: mysqli_stmt_free_result($stmt);
! 55: mysqli_stmt_close($stmt);
! 56:
! 57: } else {
! 58: printf("[010] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
! 59: }
! 60:
! 61:
! 62: if (function_exists('mysqli_stmt_get_result')) {
! 63:
! 64: if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p'))
! 65: printf("[019] [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
! 66:
! 67: if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;')) {
! 68: // no result set, one output parameter
! 69: if (!$stmt = mysqli_prepare($link, 'CALL p(@version)'))
! 70: printf("[020] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 71:
! 72: if (!mysqli_stmt_execute($stmt))
! 73: printf("[021] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 74:
! 75: if (!mysqli_stmt_close($stmt))
! 76: printf("[022] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 77:
! 78: if (!$stmt = mysqli_prepare($link, 'SELECT @version AS _version'))
! 79: printf("[023] Cannot prepare SELECT, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 80:
! 81: if (!mysqli_stmt_execute($stmt))
! 82: printf("[024] Cannot execute SELECT, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 83:
! 84: if (!$res = mysqli_stmt_get_result($stmt))
! 85: printf("[025] Cannot get result set, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 86:
! 87: if ((!($row = mysqli_fetch_assoc($res))) || ($row['_version'] == ""))
! 88: printf("[026] Results seem wrong, got %s, [%d] %s\n",
! 89: $row['_version'],
! 90: mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 91:
! 92: mysqli_free_result($res);
! 93: mysqli_stmt_close($stmt);
! 94:
! 95: } else {
! 96: printf("[027] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
! 97: }
! 98:
! 99: }
! 100:
! 101: if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p'))
! 102: printf("[028] [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
! 103:
! 104: 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;')) {
! 105: // no result set, one input parameter, output parameter
! 106: // yes, I really do not want to bind input values...
! 107: if (!$stmt = mysqli_prepare($link, "CALL p('myversion', @version)"))
! 108: printf("[029] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 109:
! 110: if (!mysqli_stmt_execute($stmt))
! 111: printf("[030] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 112:
! 113: if (!mysqli_stmt_close($stmt))
! 114: printf("[031] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 115:
! 116: if (!$stmt = mysqli_prepare($link, 'SELECT @version AS _version'))
! 117: printf("[032] Cannot prepare SELECT, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 118:
! 119: if (!mysqli_stmt_execute($stmt))
! 120: printf("[033] Cannot execute SELECT, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 121:
! 122: $version = 'unknown';
! 123: if (!mysqli_stmt_bind_result($stmt, $version) ||
! 124: !mysqli_stmt_fetch($stmt))
! 125: printf("[034] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 126:
! 127: if ($version != "myversion")
! 128: printf("[035] Results seem wrong, got %s, [%d] %s\n",
! 129: $version,
! 130: mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 131:
! 132: mysqli_stmt_free_result($stmt);
! 133: mysqli_stmt_close($stmt);
! 134:
! 135: } else {
! 136: printf("[036] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
! 137: }
! 138:
! 139: if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p'))
! 140: printf("[037] [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
! 141:
! 142: 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;')) {
! 143: // no result set, one input parameter, output parameter
! 144: // yes, I really do not want to bind input values...
! 145: if (!$stmt = mysqli_prepare($link, 'CALL p(?, @version)'))
! 146: printf("[038] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 147:
! 148: $version = 'myversion';
! 149: if (!mysqli_stmt_bind_param($stmt, 's', $version))
! 150: printf("[039] Cannot bind input parameter, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 151:
! 152: if (!mysqli_stmt_execute($stmt))
! 153: printf("[040] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 154:
! 155: if (!mysqli_stmt_close($stmt))
! 156: printf("[041] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 157:
! 158: if (!$stmt = mysqli_prepare($link, 'SELECT @version AS _version'))
! 159: printf("[042] Cannot prepare SELECT, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 160:
! 161: if (!mysqli_stmt_execute($stmt))
! 162: printf("[043] Cannot execute SELECT, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 163:
! 164: $version = 'unknown';
! 165: if (!mysqli_stmt_bind_result($stmt, $version) ||
! 166: !mysqli_stmt_fetch($stmt))
! 167: printf("[044] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 168:
! 169: if ($version !== "myversion")
! 170: printf("[045] Results seem wrong, got %s, [%d] %s\n",
! 171: $version,
! 172: mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 173:
! 174: mysqli_stmt_free_result($stmt);
! 175: mysqli_stmt_close($stmt);
! 176:
! 177: } else {
! 178: printf("[046] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
! 179: }
! 180:
! 181: mysqli_close($link);
! 182: print "done!";
! 183: ?>
! 184: --CLEAN--
! 185: <?php
! 186: require_once("connect.inc");
! 187: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
! 188: printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
! 189:
! 190: if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
! 191: printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 192:
! 193: @mysqli_query($link, 'DROP PROCEDURE IF EXISTS p');
! 194:
! 195: mysqli_close($link);
! 196: ?>
! 197: --EXPECTF--
! 198: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>