019.phpt 2.6 KB

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