bug_61207.phpt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. --TEST--
  2. PDO MySQL Bug #61207 (PDO::nextRowset() after a multi-statement query doesn't always work)
  3. --EXTENSIONS--
  4. pdo_mysql
  5. --SKIPIF--
  6. <?php
  7. require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
  8. MySQLPDOTest::skip();
  9. ?>
  10. --FILE--
  11. <?php
  12. require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
  13. /** @var PDO $db */
  14. $db = MySQLPDOTest::factory();
  15. $db->query('DROP TABLE IF EXISTS test');
  16. $db->query('create table `test`( `id` int )');
  17. $handle1 = $db->prepare('insert into test(id) values(1);
  18. select * from test where id = ?;
  19. update test set id = 2 where id = ?;');
  20. $handle1->bindValue(1, '1');
  21. $handle1->bindValue(2, '1');
  22. $handle1->execute();
  23. $i = 1;
  24. print("Handle 1:\n");
  25. do {
  26. print('Rowset ' . $i++ . "\n");
  27. if ($handle1->columnCount() > 0)
  28. print("Results detected\n");
  29. } while($handle1->nextRowset());
  30. $handle2 = $db->prepare('select * from test where id = ?;
  31. update test set id = 1 where id = ?;');
  32. $handle2->bindValue(1, '2');
  33. $handle2->bindValue(2, '2');
  34. $handle2->execute();
  35. $i = 1;
  36. print("Handle 2:\n");
  37. do {
  38. print('Rowset ' . $i++ . "\n");
  39. if ($handle2->columnCount() > 0)
  40. print("Results detected\n");
  41. } while($handle2->nextRowset());
  42. $handle3 = $db->prepare('update test set id = 2 where id = ?;
  43. select * from test where id = ?;');
  44. $handle3->bindValue(1, '1');
  45. $handle3->bindValue(2, '2');
  46. $handle3->execute();
  47. $i = 1;
  48. print("Handle 3:\n");
  49. do {
  50. print('Rowset ' . $i++ . "\n");
  51. if ($handle3->columnCount() > 0)
  52. print("Results detected\n");
  53. } while($handle3->nextRowset());
  54. $handle4 = $db->prepare('insert into test(id) values(3);
  55. update test set id = 2 where id = ?;
  56. select * from test where id = ?;');
  57. $handle4->bindValue(1, '3');
  58. $handle4->bindValue(2, '2');
  59. $handle4->execute();
  60. $i = 1;
  61. print("Handle 4:\n");
  62. do {
  63. print('Rowset ' . $i++ . "\n");
  64. if ($handle1->columnCount() > 0)
  65. print("Results detected\n");
  66. } while($handle1->nextRowset());
  67. $db->query("DROP TABLE test");
  68. ?>
  69. --CLEAN--
  70. <?php
  71. require __DIR__ . '/mysql_pdo_test.inc';
  72. MySQLPDOTest::dropTestTable();
  73. ?>
  74. --EXPECT--
  75. Handle 1:
  76. Rowset 1
  77. Rowset 2
  78. Results detected
  79. Rowset 3
  80. Handle 2:
  81. Rowset 1
  82. Results detected
  83. Rowset 2
  84. Handle 3:
  85. Rowset 1
  86. Rowset 2
  87. Results detected
  88. Handle 4:
  89. Rowset 1
  90. Rowset 2
  91. Rowset 3
  92. Results detected