bug32405.phpt 1.5 KB

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