025.phpt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. --TEST--
  2. mysqli bind_param/bind_result tinyint values
  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. mysqli_select_db($link, $db);
  15. mysqli_query($link, "SET sql_mode=''");
  16. mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
  17. mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint,
  18. c2 tinyint unsigned,
  19. c3 tinyint not NULL,
  20. c4 tinyint,
  21. c5 tinyint,
  22. c6 tinyint unsigned,
  23. c7 tinyint)");
  24. $stmt = mysqli_prepare ($link, "INSERT INTO test_bind_fetch VALUES(?,?,?,?,?,?,?)");
  25. mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
  26. $c1 = -23;
  27. $c2 = 300;
  28. $c3 = 0;
  29. $c4 = -100;
  30. $c5 = -127;
  31. $c6 = 30;
  32. $c7 = 0;
  33. mysqli_stmt_execute($stmt);
  34. mysqli_stmt_close($stmt);
  35. mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,300,0,-100,-127,+30,0)");
  36. $c1 = $c2 = $c3 = $c4 = $c5 = $c6 = $c7 = NULL;
  37. $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
  38. mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
  39. mysqli_stmt_execute($stmt);
  40. mysqli_stmt_fetch($stmt);
  41. $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
  42. var_dump($test);
  43. mysqli_stmt_close($stmt);
  44. mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
  45. mysqli_close($link);
  46. print "done!";
  47. ?>
  48. --CLEAN--
  49. <?php
  50. require_once("connect.inc");
  51. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  52. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  53. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
  54. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  55. mysqli_close($link);
  56. ?>
  57. --EXPECT--
  58. array(7) {
  59. [0]=>
  60. int(-23)
  61. [1]=>
  62. int(255)
  63. [2]=>
  64. int(0)
  65. [3]=>
  66. int(-100)
  67. [4]=>
  68. int(-127)
  69. [5]=>
  70. int(30)
  71. [6]=>
  72. int(0)
  73. }
  74. done!