002.phpt 2.2 KB

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