026.phpt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. --TEST--
  2. mysqli bind_param/bind_result with send_long_data
  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, "SET sql_mode=''");
  15. mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
  16. mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 varchar(10), c2 text)");
  17. $stmt = mysqli_prepare ($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
  18. mysqli_stmt_bind_param($stmt, "sb", $c1, $c2);
  19. $c1 = "Hello World";
  20. mysqli_stmt_send_long_data($stmt, 1, "This is the first sentence.");
  21. mysqli_stmt_send_long_data($stmt, 1, " And this is the second sentence.");
  22. mysqli_stmt_send_long_data($stmt, 1, " And finally this is the last sentence.");
  23. mysqli_stmt_execute($stmt);
  24. mysqli_stmt_close($stmt);
  25. $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
  26. mysqli_stmt_bind_result($stmt, $d1, $d2);
  27. mysqli_stmt_execute($stmt);
  28. mysqli_stmt_fetch($stmt);
  29. $test = array($d1,$d2);
  30. var_dump($test);
  31. mysqli_stmt_close($stmt);
  32. mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
  33. mysqli_close($link);
  34. print "done!";
  35. ?>
  36. --CLEAN--
  37. <?php
  38. require_once("connect.inc");
  39. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  40. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  41. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
  42. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  43. mysqli_close($link);
  44. ?>
  45. --EXPECTF--
  46. array(2) {
  47. [0]=>
  48. %unicode|string%(10) "Hello Worl"
  49. [1]=>
  50. %unicode|string%(99) "This is the first sentence. And this is the second sentence. And finally this is the last sentence."
  51. }
  52. done!