004.phpt 2.5 KB

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