004.phpt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. --TEST--
  2. mysqli fetch char/text
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. include ("connect.inc");
  12. /*** test mysqli_connect 127.0.0.1 ***/
  13. $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
  14. mysqli_select_db($link, $db);
  15. if (!mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"))
  16. printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  17. if (!mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text) ENGINE=" . $engine))
  18. printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  19. if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', 'this is a test0')"))
  20. printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  21. if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567891', 'this is a test1')"))
  22. printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  23. if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567892', 'this is a test2')"))
  24. printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  25. if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567893', 'this is a test3')"))
  26. printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  27. if (!$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch ORDER BY c1"))
  28. printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  29. $c1 = $c2 = NULL;
  30. mysqli_stmt_bind_result($stmt, $c1, $c2);
  31. mysqli_stmt_execute($stmt);
  32. $i = 4;
  33. while ($i--) {
  34. mysqli_stmt_fetch($stmt);
  35. $test = array($c1, $c2);
  36. var_dump($test);
  37. }
  38. mysqli_stmt_close($stmt);
  39. mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
  40. mysqli_close($link);
  41. print "done!";
  42. ?>
  43. --CLEAN--
  44. <?php
  45. require_once("connect.inc");
  46. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  47. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  48. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
  49. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  50. mysqli_close($link);
  51. ?>
  52. --EXPECT--
  53. array(2) {
  54. [0]=>
  55. string(10) "1234567890"
  56. [1]=>
  57. string(15) "this is a test0"
  58. }
  59. array(2) {
  60. [0]=>
  61. string(10) "1234567891"
  62. [1]=>
  63. string(15) "this is a test1"
  64. }
  65. array(2) {
  66. [0]=>
  67. string(10) "1234567892"
  68. [1]=>
  69. string(15) "this is a test2"
  70. }
  71. array(2) {
  72. [0]=>
  73. string(10) "1234567893"
  74. [1]=>
  75. string(15) "this is a test3"
  76. }
  77. done!