1--TEST-- 2Bug #66124 (mysqli under mysqlnd loses precision when bind_param with 'i') 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('connect.inc'); 7require_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 17$table_insert = "INSERT INTO `bug66124` SET `id`=?"; 18$table_select = "SELECT * FROM `bug66124`"; 19$table_delete = "DELETE FROM `bug66124`"; 20$id = '1311200011005001566'; 21 22 23require_once('connect.inc'); 24 25if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { 26 printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", 27 $host, $user, $db, $port, $socket); 28 exit(1); 29} 30 31$link->query($table_drop); 32$link->query($table_create); 33 34$stmt = $link->prepare($table_insert); 35if (!$stmt) { 36 printf("Can't prepare\n"); 37 exit(1); 38} 39 40echo "Using 'i':\n"; 41$stmt->bind_param('i', $id); 42 43if ($stmt->execute()){ 44 echo "insert id:{$id}=>{$stmt->insert_id}\n"; 45} else { 46 printf("Can't execute\n"); 47 exit(1); 48} 49 50 51$result = $link->query($table_select); 52 53if ($result){ 54 while ($row = $result->fetch_assoc()) { 55 echo "fetch id:{$row['id']}\n"; 56 } 57} else { 58 printf("Can't select\n"); 59 exit(1); 60} 61 62$stmt->close(); 63 64$link->query($table_drop); 65$link->query($table_create); 66 67 68$stmt = $link->prepare($table_insert); 69$stmt->bind_param('s', $id); 70 71echo "Using 's':\n"; 72 73if ($stmt->execute()){ 74 echo "insert id:{$id}\n"; 75} else{ 76 printf("Can't execute\n"); 77 exit(1); 78} 79 80$result = $link->query($table_select); 81 82if ($result){ 83 while ($row = $result->fetch_assoc()) { 84 echo "fetch id:{$row['id']}\n"; 85 } 86} else { 87 printf("Can't select\n"); 88 exit(1); 89} 90 91$link->close(); 92?> 93done 94--EXPECTF-- 95Using 'i': 96insert id:1311200011005001566=>1311200011005001566 97fetch id:1311200011005001566 98Using 's': 99insert id:1311200011005001566 100fetch id:1311200011005001566 101done