bug66124.phpt 2.0 KB

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