Annotation of embedaddon/php/ext/mysqli/tests/mysqli_stmt_get_result_non_select.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: mysqli_stmt_get_result() - SHOW, DESCRIBE, EXPLAIN
! 3: --SKIPIF--
! 4: <?php
! 5: require_once('skipif.inc');
! 6: require_once('skipifemb.inc');
! 7: require_once('skipifconnectfailure.inc');
! 8:
! 9: if (!function_exists('mysqli_stmt_get_result'))
! 10: die('skip mysqli_stmt_get_result not available');
! 11: ?>
! 12: --FILE--
! 13: <?php
! 14: /*
! 15: NOTE: no datatype tests here! This is done by
! 16: mysqli_stmt_bind_result.phpt already. Restrict
! 17: this test case to the basics.
! 18: */
! 19: require('table.inc');
! 20:
! 21: if (!$stmt = mysqli_stmt_init($link))
! 22: printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 23:
! 24: if (mysqli_query($link, 'PREPARE mystmt FROM "SHOW ENGINES"')) {
! 25: mysqli_query($link, 'DEALLOCATE PREPARE mystmt');
! 26:
! 27: if (!$stmt->prepare('SHOW ENGINES') ||
! 28: !$stmt->execute())
! 29: printf("[002] [%d] %s\n", $stmt->errno, $stmt->error);
! 30:
! 31: if (!$res = $stmt->get_result())
! 32: printf("[003] [%d] %s\n", $stmt->errno, $stmt->error);
! 33:
! 34: $engines = mysqli_fetch_all($res, MYSQLI_NUM);
! 35: if (empty($engines)) {
! 36: printf("[004] It is very unlikely that SHOW ENGINES returns no data, check manually\n");
! 37: } else {
! 38: $found = false;
! 39: foreach ($engines as $k => $engine)
! 40: foreach ($engine as $k => $v)
! 41: if (stristr('MyISAM', $v)) {
! 42: $found = true;
! 43: break;
! 44: }
! 45: if (!$found)
! 46: printf("[005] It is very unlikely that SHOW ENGINES does not show MyISAM, check manually\n");
! 47: }
! 48: mysqli_free_result($res);
! 49: }
! 50:
! 51: if (mysqli_query($link, 'PREPARE mystmt FROM "DESCRIBE test id"')) {
! 52: mysqli_query($link, 'DEALLOCATE PREPARE mystmt');
! 53:
! 54: if (!$stmt->prepare('DESCRIBE test id') ||
! 55: !$stmt->execute())
! 56: printf("[006] [%d] %s\n", $stmt->errno, $stmt->error);
! 57:
! 58: if (!$res = $stmt->get_result())
! 59: printf("[007] [%d] %s\n", $stmt->errno, $stmt->error);
! 60:
! 61: $description = mysqli_fetch_assoc($res);
! 62: if ($description['Field'] != 'id') {
! 63: printf("[008] Returned data seems wrong, [%d] %s\n",
! 64: mysqli_errno($link), mysqli_error($link));
! 65: var_dump($description);
! 66: }
! 67: mysqli_free_result($res);
! 68: }
! 69:
! 70: if (mysqli_query($link, 'PREPARE mystmt FROM "EXPLAIN SELECT id FROM test"')) {
! 71: mysqli_query($link, 'DEALLOCATE PREPARE mystmt');
! 72:
! 73: if (!$stmt->prepare('EXPLAIN SELECT id FROM test') ||
! 74: !$stmt->execute())
! 75: printf("[009] [%d] %s\n", $stmt->errno, $stmt->error);
! 76:
! 77: if (!$res = $stmt->get_result())
! 78: printf("[010] [%d] %s\n", $stmt->errno, $stmt->error);
! 79:
! 80: $tmp = mysqli_fetch_assoc($res);
! 81: if (empty($tmp))
! 82: printf("[011] Empty EXPLAIN result set seems wrong, check manually, [%d] %s\n",
! 83: mysqli_errno($link), mysqli_error($link));
! 84: mysqli_free_result($res);
! 85: }
! 86: mysqli_close($link);
! 87:
! 88: print "done!";
! 89: ?>
! 90: --CLEAN--
! 91: <?php
! 92: require_once("clean_table.inc");
! 93: ?>
! 94: --EXPECTF--
! 95: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>