The following are what I saw elsewhere. Little trouble: As usual, we use a stored procedure procA of MS Sql Server, which gives an output parameter nReturn, And a result set is returned. We encountered a little trouble when asking PHP to call this procA. You can’t have your cake and eat it too: I originally hoped that such code could get both the output parameters and the returned result set:
Although I got Result set, however, the $nReturn parameter cannot get the output parameters. If you change the last sentence to: $db_mssql->Query_ID = mssql_execute($stmt,true); The output parameters are obtained, but the result set is gone. It seems like you can't have your cake and eat it too. Can't PHP even do this? This issue is not mentioned in the PHP manual. Explanation from the PHP maintainer: Originally, our calling method was definitely supported before PHP 4.3. "However, since PHP version 4.3," they said, "in order to be compatible with stored procedures returning multiple result sets, PHP has changed this feature." "If you don't need the result set, you should set the second optional parameter of mssql_execute to TRUE, so that you can get the output parameters after the mssql_execute method." "If you need to return result sets, you should call mssql_next_result once for each result set. After the last result set is returned, you will get the return value FALSE by calling mssql_next_result. At this time, you can access the output parameters ” solve: Add a sentence at the end:
Immediately, the magic took effect: PHP populates $nRetVal with the correct output parameters. |