[php-src] Issue #11552: PDO_DBLIB: Fetching from statements sharing a conection results in wrong values being returned
| From: | harrison3000 | Date: | Wed, 28 Jun 2023 15:11:44 +0000 |
| Subject: | [php-src] Issue #11552: PDO_DBLIB: Fetching from statements sharing a conection results in wrong values being returned | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244831@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11552
Author: harrison3000
### Description
When using pdo_dblib, making 2 queries at the same time using the same conection results in corrupt
statements
The keys are correct, but the results are from the last query
It's as if both statements are somehow sharing the same cursor under the hood
The following code:
```php
<?php
$user = "REDACTED";
$pass = "REDACTED";
$host = "REDACTED";
$db = "REDACTED";
$con = new \PDO("dblib:host=$host;dbname=$db;version=7.3;charset=UTF-8",$user,$pass,array(
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
));
$sta = $con->query("SELECT *
FROM (
VALUES ('A0'),
('A1'),
('A2')
) AS MyTable(A)");
$stb = $con->query("SELECT *
FROM (
VALUES ('B0'),
('B1'),
('B2')
) AS MyTable(B)");
var_export($sta->fetch()); echo "\n";
var_export($stb->fetch()); echo "\n";
var_export($sta->fetch()); echo "\n";
var_export($stb->fetch()); echo "\n";
```
Resulted in this output:
```
array (
'A' => 'B0',
)
array (
'B' => 'B1',
)
array (
'A' => 'B2',
)
false
```
But I expected this output instead:
```
array (
'A' => 'A0',
)
array (
'B' => 'B0',
)
array (
'A' => 'A1',
)
array (
'B' => 'B1',
)
```
### PHP Version
PHP 8.2.7
### Operating System
Ubuntu 23.04