005.phpt 1.7 KB

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