009.phpt 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. --TEST--
  2. mysqli fetch bigint values (ok to fail with 4.1.x)
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. if (PHP_INT_SIZE == 8) {
  8. echo 'skip test valid only for 32bit systems';
  9. exit;
  10. }
  11. require_once('skipifconnectfailure.inc');
  12. ?>
  13. --FILE--
  14. <?php
  15. require_once("connect.inc");
  16. /*** test mysqli_connect 127.0.0.1 ***/
  17. $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
  18. if (!mysqli_query($link, "SET sql_mode=''"))
  19. printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  20. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
  21. printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  22. $rc = mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 bigint default 5,
  23. c2 bigint,
  24. c3 bigint not NULL,
  25. c4 bigint unsigned,
  26. c5 bigint unsigned,
  27. c6 bigint unsigned,
  28. c7 bigint unsigned,
  29. c8 bigint unsigned) ENGINE=" . $engine);
  30. if (!$rc)
  31. printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  32. $rc = mysqli_query($link, "INSERT INTO test_bind_fetch (c2,c3,c4,c5,c6,c7,c8) ".
  33. "VALUES (-23,4.0,33333333333333,0,-333333333333,99.9,1234)");
  34. if (!$rc)
  35. printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  36. $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
  37. mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
  38. mysqli_stmt_execute($stmt);
  39. $rc = mysqli_stmt_fetch($stmt);
  40. if (mysqli_get_server_version($link) < 50000) {
  41. // 4.1 is faulty and will return big number for $c6
  42. if ($c6 == "18446743740376218283") {
  43. $c6 = 0;
  44. }
  45. }
  46. $c8 = 4567;// change this to test how mysqli/mysqlnd handles is_ref changing
  47. $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8);
  48. var_dump($test);
  49. mysqli_stmt_close($stmt);
  50. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch_uint"))
  51. printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  52. $rc = mysqli_query($link, "CREATE TABLE test_bind_fetch_uint(c1 integer unsigned, c2 integer unsigned) ENGINE=" . $engine);
  53. if (!$rc)
  54. printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  55. if (!mysqli_query($link, "INSERT INTO test_bind_fetch_uint (c1,c2) VALUES (20123456, 3123456789)"))
  56. printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  57. $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_uint");
  58. mysqli_stmt_bind_result($stmt, $c1, $c2);
  59. mysqli_stmt_execute($stmt);
  60. $rc = mysqli_stmt_fetch($stmt);
  61. echo $c1, "\n", $c2, "\n";
  62. mysqli_stmt_close($stmt);
  63. mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
  64. mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch_uint");
  65. mysqli_close($link);
  66. print "done!";
  67. ?>
  68. --CLEAN--
  69. <?php
  70. require_once("connect.inc");
  71. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  72. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  73. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
  74. printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  75. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch_uint"))
  76. printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  77. mysqli_close($link);
  78. ?>
  79. --EXPECT--
  80. array(8) {
  81. [0]=>
  82. int(5)
  83. [1]=>
  84. int(-23)
  85. [2]=>
  86. int(4)
  87. [3]=>
  88. string(14) "33333333333333"
  89. [4]=>
  90. int(0)
  91. [5]=>
  92. int(0)
  93. [6]=>
  94. int(100)
  95. [7]=>
  96. int(4567)
  97. }
  98. 20123456
  99. 3123456789
  100. done!