019.phpt 2.3 KB

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