005.phpt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. --TEST--
  2. mysqli fetch char/text long
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once("connect.inc");
  12. /*** test mysqli_connect 127.0.0.1 ***/
  13. $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
  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. $a = str_repeat("A1", 32000);
  19. mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', '$a')");
  20. $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
  21. mysqli_stmt_bind_result($stmt, $c1, $c2);
  22. mysqli_stmt_execute($stmt);
  23. mysqli_stmt_fetch($stmt);
  24. $test[] = $c1;
  25. $test[] = ($a == $c2) ? "32K String ok" : "32K String failed";
  26. var_dump($test);
  27. /* this will crash with libmysql from PHP 5.0.6 (or earlier) to 5.3.0 */
  28. mysqli_stmt_fetch($stmt);
  29. mysqli_stmt_close($stmt);
  30. mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
  31. mysqli_close($link);
  32. print "done!";
  33. ?>
  34. --CLEAN--
  35. <?php
  36. require_once("connect.inc");
  37. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  38. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  39. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
  40. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  41. mysqli_close($link);
  42. ?>
  43. --EXPECT--
  44. array(2) {
  45. [0]=>
  46. string(10) "1234567890"
  47. [1]=>
  48. string(13) "32K String ok"
  49. }
  50. done!