MSSQL データベースから複数の結果セットを返すストアド プロシージャがあります。私が抱えている問題は、各結果セットをループすることです。Yii は、行を反復処理するために次の結果セットに進んでいないようです。次に例を示します。
結果 1:
TOTAL
-----
999
結果 2:
ID |NAME
---|----
0 | Jon
1 | Bob
2 | Sarah
3 | Pete
そして、これが Yii でこの作業を行う私の試みです。
//create the call to stored proc
$command=parent::$db->createCommand("exec sp_showUsers");
//run the query
$dataReader = $command->query();
//For the current object assign the row to a variable
while (($row = $dataReader->read()) !== false){
//if the row has a total column
if(isset($row['total'])){
$total = $row['total'];
}
}
//Test if there is another result
$usersExist = $dataReader->nextResult();
//$dataReader->next(); - REMOVED AS NOT NEEDED
if($usersExist){
$userTable = array();
$i = 0;
while (($userRow = $dataReader->read())!== false){
//add each row to a temporary array
$userTable[$i] = $userRow['id'];
$i++;
}
}
...
->next()
メソッドが呼び出されたにもかかわらず、これは 2 番目の結果セットをループしていないように見えますか? どんな助けでも大歓迎です!ありがとう。
sqlsrv_next_result()
Ps ストアド プロシージャは機能し、通常の PHP とメソッドを使用して結果をループできます。