048.phpt 1.8 KB

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