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
+
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
+
23
+ require_once ('connect.inc ' );
24
+
25
+ if (!$ 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 );
35
+ if (!$ stmt ) {
36
+ printf ("Can't prepare \n" );
37
+ exit (1 );
38
+ }
39
+
40
+ echo "Using 'i': \n" ;
41
+ $ stmt ->bind_param ('i ' , $ id );
42
+
43
+ if ($ 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
+
53
+ if ($ 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
+
71
+ echo "Using 's': \n" ;
72
+
73
+ if ($ 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
+
82
+ if ($ 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
+ ?>
93
+ done
94
+ --EXPECTF--
95
+ Using 'i':
96
+ insert id:1311200011005001566=>1311200011005001566
97
+ fetch id:1311200011005001566
98
+ Using 's':
99
+ insert id:1311200011005001566
100
+ fetch id:1311200011005001566
101
+ done
0 commit comments