I'm in the process of converting a PHP application from running in a Windows environment to a Linux based environment.
It utilises PDO to run Stored Procedures against a Microsoft SQL Server database.
So, I've installed and configured PHP 5.6.22, Apache, freetds and pdo dblib to facilitate the application.
Most stored procedure executions are working perfectly. Except ones that return multiple rowsets.
When I call $pdo->nextRowset()
, I get this fatal error:
SQLSTATE[HY000]: General error: PDO_DBLIB: dbresults() returned FAIL
The only reference I can find to this was a bug reported in PHP 5.6.9 that was fixed.
However, I am getting the same issue in PHP 5.6.22.
Does anyone have any ideas why this is happening and how I can resolve it?
Are you fetching data with PDO::fetch
or PDO::fetchAll
? Because if you use the "fetch" method and don't reach the end of the rows PDO::nextRowset()
will fail (I don't know why, it just happened to me).
So, for me works to force to scan all rows until PDO::fetch
returns false, then PDO::nextRowset()
will execute normally.
It means that if you have only one row in a rowset you must call PDO::fetch
at least two time (1 for retrieve data and 1 to return false) and then pass to next rowset.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With