mysqli_stmt_multires.phpt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. --TEST--
  2. Multiple result set with PS
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once("connect.inc");
  8. if (!$IS_MYSQLND) {
  9. die("skip mysqlnd only test");
  10. }
  11. require_once('skipifconnectfailure.inc');
  12. ?>
  13. --FILE--
  14. <?php
  15. require_once("connect.inc");
  16. require('table.inc');
  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. 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")) {
  22. printf("[002] [%d] %s\n", $link->error, $link->errno);
  23. }
  24. if (!($stmt = $link->prepare("CALL p123"))) {
  25. printf("[003] [%d] %s\n", $stmt->error, $stmt->errno);
  26. }
  27. if (!$stmt->execute()) {
  28. printf("[005] [%d] %s\n", $stmt->error, $stmt->errno);
  29. }
  30. $c_id = NULL;
  31. $c_label = NULL;
  32. if (!$stmt->bind_result($c_id, $c_label)) {
  33. printf("[004] [%d] %s\n", $stmt->error, $stmt->errno);
  34. }
  35. var_dump("pre:",$c_id, $c_label);
  36. if (!$stmt->fetch()) {
  37. printf("[006] [%d] %s\n", $stmt->error, $stmt->errno);
  38. }
  39. var_dump("post:",$c_id, $c_label);
  40. if ($stmt->fetch()) {
  41. printf("[007] Shouldn't have fetched anything\n");
  42. var_dump($c_id, $c_label);
  43. }
  44. if ($stmt->fetch()) {
  45. printf("[008] No more rows expected\n");
  46. }
  47. if (!$stmt->more_results()) {
  48. printf("[009] Expected more results\n");
  49. } else {
  50. var_dump("[009] next_result:", $stmt->next_result());
  51. }
  52. if (!$stmt->bind_result($c_id, $c_label)) {
  53. printf("[010] [%d] %s\n", $stmt->error, $stmt->errno);
  54. }
  55. var_dump("pre:",$c_id, $c_label);
  56. if (!$stmt->fetch()) {
  57. printf("[011] [%d] %s\n", $stmt->error, $stmt->errno);
  58. }
  59. var_dump("post:",$c_id, $c_label);
  60. if ($stmt->fetch()) {
  61. printf("[012] No more rows expected\n");
  62. }
  63. if (!$stmt->more_results()) {
  64. printf("[013] Expected more results\n");
  65. } else {
  66. var_dump("[013] next_result:", $stmt->next_result());
  67. }
  68. if ($stmt->more_results()) {
  69. printf("[014] No more results expected\n");
  70. } else {
  71. printf("[014] No result, as expected\n");
  72. }
  73. $stmt->close();
  74. $link->close();
  75. echo "done";
  76. ?>
  77. --CLEAN--
  78. <?php
  79. require_once 'connect.inc';
  80. $link = new mysqli($host, $user, $passwd, $db, $port, $socket);
  81. $link->query('DROP PROCEDURE IF EXISTS p123');
  82. $link->close();
  83. ?>
  84. --EXPECT--
  85. string(4) "pre:"
  86. NULL
  87. NULL
  88. string(5) "post:"
  89. int(13)
  90. string(6) "a-ahoi"
  91. string(18) "[009] next_result:"
  92. bool(true)
  93. string(4) "pre:"
  94. int(13)
  95. string(6) "a-ahoi"
  96. string(5) "post:"
  97. int(43)
  98. string(5) "a---a"
  99. string(18) "[013] next_result:"
  100. bool(true)
  101. [014] No result, as expected
  102. done