048.phpt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. --TEST--
  2. mysqli bind_result (OO-Style)
  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. $mysql = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
  13. $mysql->select_db($db);
  14. $mysql->query("DROP TABLE IF EXISTS test_fetch_null");
  15. $mysql->query("CREATE TABLE test_fetch_null(col1 tinyint, col2 smallint,
  16. col3 int, col4 bigint,
  17. col5 float, col6 double,
  18. col7 date, col8 time,
  19. col9 varbinary(10),
  20. col10 varchar(50),
  21. col11 char(20)) ENGINE=" . $engine);
  22. $mysql->query("INSERT INTO test_fetch_null(col1,col10, col11) VALUES(1,'foo1', 1000),(2,'foo2', 88),(3,'foo3', 389789)");
  23. $stmt = $mysql->prepare("SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 from test_fetch_null");
  24. $stmt->bind_result($c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11);
  25. $stmt->execute();
  26. $stmt->fetch();
  27. $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11);
  28. var_dump($test);
  29. $stmt->close();
  30. $mysql->query("DROP TABLE IF EXISTS test_fetch_null");
  31. $mysql->close();
  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_fetch_null"))
  40. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  41. mysqli_close($link);
  42. ?>
  43. --EXPECTF--
  44. array(11) {
  45. [0]=>
  46. int(1)
  47. [1]=>
  48. NULL
  49. [2]=>
  50. NULL
  51. [3]=>
  52. NULL
  53. [4]=>
  54. NULL
  55. [5]=>
  56. NULL
  57. [6]=>
  58. NULL
  59. [7]=>
  60. NULL
  61. [8]=>
  62. NULL
  63. [9]=>
  64. %unicode|string%(4) "foo1"
  65. [10]=>
  66. %unicode|string%(4) "1000"
  67. }
  68. done!