G2A Many GEOs
SHARE
TWEET

PDO nextRowset() bug report

a guest Feb 28th, 2012 524 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $link = new \PDO('mysql:host=localhost;dbname=test', 'user', 'password');
  3.  
  4. //WORKS: INSERT, followed by SELECT, followed UPDATE
  5. //Output:
  6. //Rowset 1
  7. //Rowset 2
  8. //Results detected
  9. $handle1 = $link->prepare('insert into testtable(id) values(1);
  10.                           select * from testtable where id = ?;
  11.                           update testtable set id = 2 where id = ?;');
  12.  
  13. $handle1->bindValue('1', '1');
  14. $handle1->bindValue('2', '1');
  15.  
  16. $handle1->execute();
  17.  
  18. $i = 1;
  19. print("Handle 1:\n");
  20. do{
  21.         print('Rowset ' . $i++ . "\n");
  22.         if($handle1->columnCount() > 0)
  23.                 print("Results detected\n");
  24. }while($handle1->nextRowset());
  25.  
  26.  
  27.  
  28.  
  29.  
  30. //WORKS: SELECT, followed by UPDATE
  31. //Output:
  32. //Rowset 1
  33. //Results detected
  34. $handle2 = $link->prepare('select * from testtable where id = ?;
  35.                            update testtable set id = 1 where id = ?;');
  36.  
  37. $handle2->bindValue('1', '2');
  38. $handle2->bindValue('2', '2');
  39.  
  40. $handle2->execute();
  41.  
  42. $i = 1;
  43. print("Handle 2:\n");
  44. do{
  45.         print('Rowset ' . $i++ . "\n");
  46.         if($handle2->columnCount() > 0)
  47.                 print("Results detected\n");
  48. }while($handle2->nextRowset());
  49.  
  50.  
  51.  
  52.  
  53.  
  54. //WORKS: UPDATE, followed by SELECT
  55. //Output:
  56. //Rowset 1
  57. //Rowset 2
  58. //Results detected
  59. $handle3 = $link->prepare('update testtable set id = 2 where id = ?;
  60.                           select * from testtable where id = ?;');
  61.  
  62. $handle3->bindValue('1', '1');
  63. $handle3->bindValue('2', '2');
  64.  
  65. $handle3->execute();
  66.  
  67. $i = 1;
  68. print("Handle 3:\n");
  69. do{
  70.         print('Rowset ' . $i++ . "\n");
  71.         if($handle3->columnCount() > 0)
  72.                 print("Results detected\n");
  73. }while($handle3->nextRowset());
  74.  
  75.  
  76.  
  77.  
  78.  
  79. //DOESN'T WORK: INSERT, followed by UPDATE, followed by SELECT
  80. //Output:
  81. //Rowset 1
  82. //Expected output: same as examples 1 and 3
  83. $handle4 = $link->prepare('insert into testtable(id) values(3);
  84.                           update testtable set id = 2 where id = ?;
  85.                           select * from testtable where id = ?;');
  86.  
  87. $handle4->bindValue('1', '3');
  88. $handle4->bindValue('2', '2');
  89.  
  90. $handle4->execute();
  91.  
  92. $i = 1;
  93. print("Handle 4:\n");
  94. do{
  95.         print('Rowset ' . $i++ . "\n");
  96.         if($handle1->columnCount() > 0)
  97.                 print("Results detected\n");
  98. }while($handle1->nextRowset());
  99.  
  100. ?>
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top