bug32405.phpt 1.6 KB

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