002.phpt 2.3 KB

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