011.phpt 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. --TEST--
  2. mysqli fetch mixed values
  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(50)) ENGINE=" . $engine);
  23. if (!$rc)
  24. printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  25. $rc = mysqli_query($link,"INSERT INTO test_bind_result VALUES(19,2999,3999,4999999,
  26. 2345.6,5678.89563,
  27. 'foobar','mysql rulez')");
  28. if (!$rc)
  29. printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  30. $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
  31. mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
  32. mysqli_stmt_execute($stmt);
  33. mysqli_stmt_fetch($stmt);
  34. $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8);
  35. var_dump($test);
  36. mysqli_stmt_close($stmt);
  37. mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result");
  38. mysqli_close($link);
  39. print "done!";
  40. ?>
  41. --CLEAN--
  42. <?php
  43. require_once("connect.inc");
  44. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  45. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  46. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
  47. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  48. mysqli_close($link);
  49. ?>
  50. --EXPECT--
  51. array(8) {
  52. [0]=>
  53. int(19)
  54. [1]=>
  55. int(2999)
  56. [2]=>
  57. int(3999)
  58. [3]=>
  59. int(4999999)
  60. [4]=>
  61. float(2345.6)
  62. [5]=>
  63. float(5678.89563)
  64. [6]=>
  65. string(6) "foobar"
  66. [7]=>
  67. string(11) "mysql rulez"
  68. }
  69. done!