022.phpt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. --TEST--
  2. mysqli bind_param/bind_result 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. mysqli_select_db($link, $db);
  14. mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
  15. mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
  16. $stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
  17. mysqli_stmt_bind_param($stmt, "ss", $a1, $a2);
  18. $a1 = "1234567890";
  19. $a2 = str_repeat("A1", 32000);
  20. mysqli_stmt_execute($stmt);
  21. mysqli_stmt_close($stmt);
  22. $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
  23. mysqli_stmt_bind_result($stmt, $c1, $c2);
  24. mysqli_stmt_execute($stmt);
  25. mysqli_stmt_fetch($stmt);
  26. $test[] = $c1;
  27. $test[] = ($a2 == $c2) ? "32K String ok" : "32K String failed";
  28. var_dump($test);
  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. --EXPECTF--
  44. array(2) {
  45. [0]=>
  46. %unicode|string%(10) "1234567890"
  47. [1]=>
  48. %s(13) "32K String ok"
  49. }
  50. done!