025.phpt 1.9 KB

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