1--TEST-- 2Bug #32405 (mysqli->fetch() is returning bad data) 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once 'skipifconnectfailure.inc'; 8?> 9--FILE-- 10<?php 11 require_once 'connect.inc'; 12 13 /*** test mysqli_connect 127.0.0.1 ***/ 14 $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); 15 mysqli_select_db($link, "test"); 16 mysqli_query($link, "SET sql_mode=''"); 17 18 /* two fields are needed. the problem does not occur with 1 field only selected. */ 19 $link->query("CREATE TABLE test_users(user_id int(10) unsigned NOT NULL auto_increment, login varchar(50) default '', PRIMARY KEY (user_id))"); 20 $link->query('INSERT INTO test_users VALUES (NULL, "user1"), (NULL, "user2"), (NULL, "user3"), (NULL, "user4")'); 21 22 23 if ($stmt = $link->prepare("SELECT SQL_NO_CACHE user_id, login FROM test_users")) { 24 $stmt->execute(); 25 $stmt->bind_result($col1, $col2); 26 while ($stmt->fetch()) { 27 var_dump($col1, $col2); 28 } 29 $stmt->close(); 30 } 31 32 mysqli_query($link,"DROP TABLE test_users"); 33 mysqli_close($link); 34?> 35--CLEAN-- 36<?php 37require_once 'connect.inc'; 38if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 39 printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 40 41if (!mysqli_query($link, "DROP TABLE IF EXISTS test_users")) 42 printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 43 44mysqli_close($link); 45?> 46--EXPECTF-- 47int(1) 48%s(5) "user1" 49int(2) 50%s(5) "user2" 51int(3) 52%s(5) "user3" 53int(4) 54%s(5) "user4" 55