php - Why I need PDOStatement::nextRowSet with stored procedure to get result? -
I can not understand about the stored procedure of PDO and let me clarify some clarification (and perhaps my problem) the wanted.
I am using SQL Server 2008 R2 with PHP 5.4 and Apache 2.2. I am calling a stored procedure with 2 parameters using PDO (with SQLSRV drivers):
$ pdoStmt = $ pdo-> Prepare ('MY_STORED_PROCEDURE ?,?'); $ PdoStmt-> Bind value (1, 'MyWhill1', PDO :: param_st); $ PdoStmt-> Bind value (2, 'MyView 2', PDO :: param_st); $ PdoStmt-> Executed (); Well, here, everything works perfectly, the result of the stored procedure is called an array, so I should use fetchArray () I do this: $ result = $ pdoStmt-> fetchArray ();
But the result is empty. And I do not know why, I have to call nextRowSet () several times to get results, so I do this:
{$ result = $ PdoStmt-> Get All (PDO :: FETCH_ASSOC); } While ($ pdoStmt-> nextRowSet ());
Then I have my result! Yes ....
The archived procedure works (when I execute it directly in SQL Server) (I have the right result with the same parameter).
So why do I have to do that and there is a solution for that?
Anyone in the PDO
fetchArray ( )
is not the method, if you want to get an array, then you can do something like this: $ result = $ pdoStmt-> Get (PDO :: FETCH_ASSOC);
To get an associative array.
Comments
Post a Comment