024.phpt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. --TEST--
  2. mysqli bind_param/bind_result short 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 smallint unsigned,
  17. c2 smallint unsigned,
  18. c3 smallint,
  19. c4 smallint,
  20. c5 smallint,
  21. c6 smallint unsigned,
  22. c7 smallint)");
  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 = 35999;
  27. $c3 = NULL;
  28. $c4 = -500;
  29. $c5 = -9999999;
  30. $c6 = -0;
  31. $c7 = 0;
  32. mysqli_stmt_execute($stmt);
  33. mysqli_stmt_close($stmt);
  34. $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
  35. mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
  36. mysqli_stmt_execute($stmt);
  37. mysqli_stmt_fetch($stmt);
  38. $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
  39. var_dump($test);
  40. mysqli_stmt_close($stmt);
  41. mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
  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 test_bind_fetch"))
  51. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  52. mysqli_close($link);
  53. ?>
  54. --EXPECT--
  55. array(7) {
  56. [0]=>
  57. int(0)
  58. [1]=>
  59. int(35999)
  60. [2]=>
  61. NULL
  62. [3]=>
  63. int(-500)
  64. [4]=>
  65. int(-32768)
  66. [5]=>
  67. int(0)
  68. [6]=>
  69. int(0)
  70. }
  71. done!