I try to call 3 SQL Server 2000 Stored Procedures one after the other using PDO DBLIB in PHP 5.4.4 (Linux) and I get an error at the second query : Fatal error: Call to a member function fetchAll() on a non-object
The first query works perfectly, returning results as expected. If I move query order, every time the first query succeeds and the others fail.
Also, when the exact same code is run on a PHP 5.3.14 server, everything works great.
Example code:
$dbh = new PDO ("dblib:host=myhost;dbname=mydb","user","pass");
$query = $dbh->query("EXEC dbo.storedProc1 'param1'");
$result = $query->fetchAll();
var_dump($result);
$query = $dbh->query("EXEC dbo.storedProc2 'param1'");
$result = $query->fetchAll(); // <-- Fails here
var_dump($result);
$query = $dbh->query("EXEC dbo.storedProc3 'param1'");
$result = $query->fetchAll();
var_dump($result);
Any clue to make this code run on PHP 5.4 ?
EDIT : PDO::errorInfo gives me that error : Attempt to initiate a new Adaptive Server operation with results pending [20019] (severity 7) [EXEC dbo.storedProc2 'param1']
Also, calling query
with a SELECT (SELECT 1, SELECT 3 and SELECT 3 for example) gives the same result (first result is given, following are empty)
EDIT 2 : Looks like it's related to a PHP bug, as noticed by Capilé in the comments