bug66124.phpt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. --TEST--
  2. Bug #66124 (mysqli under mysqlnd loses precision when bind_param with 'i')
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('connect.inc');
  8. require_once('skipifconnectfailure.inc');
  9. ?>
  10. --FILE--
  11. <?php
  12. $table_drop = "DROP TABLE IF EXISTS `test`";
  13. $table_create = "CREATE TABLE `test` (
  14. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  15. PRIMARY KEY (`id`)
  16. ) ENGINE=InnoDB DEFAULT CHARSET=utf8";
  17. $table_insert = "INSERT INTO `test` SET `id`=?";
  18. $table_select = "SELECT * FROM `test`";
  19. $table_delete = "DELETE FROM `test`";
  20. $id = '1311200011005001566';
  21. require_once('connect.inc');
  22. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
  23. printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  24. $host, $user, $db, $port, $socket);
  25. exit(1);
  26. }
  27. $link->query($table_drop);
  28. $link->query($table_create);
  29. $stmt = $link->prepare($table_insert);
  30. if (!$stmt) {
  31. printf("Can't prepare\n");
  32. exit(1);
  33. }
  34. echo "Using 'i':\n";
  35. $stmt->bind_param('i', $id);
  36. if ($stmt->execute()){
  37. echo "insert id:{$id}=>{$stmt->insert_id}\n";
  38. } else {
  39. printf("Can't execute\n");
  40. exit(1);
  41. }
  42. $result = $link->query($table_select);
  43. if ($result){
  44. while ($row = $result->fetch_assoc()) {
  45. echo "fetch id:{$row['id']}\n";
  46. }
  47. } else {
  48. printf("Can't select\n");
  49. exit(1);
  50. }
  51. $stmt->close();
  52. $link->query($table_drop);
  53. $link->query($table_create);
  54. $stmt = $link->prepare($table_insert);
  55. $stmt->bind_param('s', $id);
  56. echo "Using 's':\n";
  57. if ($stmt->execute()){
  58. echo "insert id:{$id}\n";
  59. } else{
  60. printf("Can't execute\n");
  61. exit(1);
  62. }
  63. $result = $link->query($table_select);
  64. if ($result){
  65. while ($row = $result->fetch_assoc()) {
  66. echo "fetch id:{$row['id']}\n";
  67. }
  68. } else {
  69. printf("Can't select\n");
  70. exit(1);
  71. }
  72. $link->close();
  73. ?>
  74. done
  75. --CLEAN--
  76. <?php
  77. require_once "clean_table.inc";
  78. ?>
  79. --EXPECT--
  80. Using 'i':
  81. insert id:1311200011005001566=>1311200011005001566
  82. fetch id:1311200011005001566
  83. Using 's':
  84. insert id:1311200011005001566
  85. fetch id:1311200011005001566
  86. done