012.phpt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. --TEST--
  2. mysqli fetch mixed values 2
  3. --INI--
  4. precision=12
  5. --EXTENSIONS--
  6. mysqli
  7. --SKIPIF--
  8. <?php
  9. require_once('skipifconnectfailure.inc');
  10. ?>
  11. --FILE--
  12. <?php
  13. require_once("connect.inc");
  14. /*** test mysqli_connect 127.0.0.1 ***/
  15. $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
  16. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
  17. printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  18. $rc = mysqli_query($link, "CREATE TABLE test_bind_result(c1 tinyint, c2 smallint,
  19. c3 int, c4 bigint,
  20. c5 float, c6 double,
  21. c7 varbinary(10),
  22. c8 varchar(10)) ENGINE=" . $engine);
  23. if (!$rc)
  24. printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  25. if (!mysqli_query($link, "INSERT INTO test_bind_result VALUES(120,2999,3999,54,
  26. 2.6,58.89,
  27. '206','6.7')"))
  28. printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  29. $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
  30. mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
  31. mysqli_stmt_execute($stmt);
  32. mysqli_stmt_fetch($stmt);
  33. $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8);
  34. var_dump($test);
  35. mysqli_stmt_close($stmt);
  36. mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result");
  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_bind_result"))
  46. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  47. mysqli_close($link);
  48. ?>
  49. --EXPECT--
  50. array(8) {
  51. [0]=>
  52. int(120)
  53. [1]=>
  54. int(2999)
  55. [2]=>
  56. int(3999)
  57. [3]=>
  58. int(54)
  59. [4]=>
  60. float(2.6)
  61. [5]=>
  62. float(58.89)
  63. [6]=>
  64. string(3) "206"
  65. [7]=>
  66. string(3) "6.7"
  67. }
  68. done!