が含まれている私は、ストアドプロシージャから複数の結果セットを取得するためにCodeIgniterの中で、このライブラリを使用しています:コール複数のストアドプロシージャは最後の結果は、前の
class Multi_Results
{
private $CI, $Data, $mysqli, $ResultSet;
/**
* The constructor
*/
function __construct()
{
$this->CI =& get_instance();
$this->Data = '';
$this->ResultSet = array();
$this->mysqli = $this->CI->db->conn_id;
}
public function GetMultiResults($SqlCommand)
{
/* execute multi query */
if (mysqli_multi_query($this->mysqli, $SqlCommand)) {
$i=1;
do
{
if ($result = $this->mysqli->store_result())
{
while ($row = $result->fetch_assoc())
{
$this->Data[$i][] = $row;
}
mysqli_free_result($result);
}
$i++;
}
while ($this->mysqli->more_results() && $this->mysqli->next_result());
}
return $this->Data;
}
}
私は
のようなコントローラからの手順を呼んでいます$result_array = $this->multi_results->GetMultiResults("CALL procedure_name($input_1, '$input_2')");
これは何をするのでしょうか。この問題は、コントローラから別の2つのプロシージャを1つずつ呼び出し、異なる変数に結果を割り当てるときに発生します。 2番目の(最後の)結果をvar_dumpするとき、1番目の結果の結果セットも含まれます。彼らの両方が既にアドオンライブラリで行われているが「mysqli_free_result」は解決策を提案 CodeIgniter active records' problems calling multiple stored proceduresとCalling a stored procedure from CodeIgniter's Active Record class : 私は(それがMSQLIに設定されている)database.phpでの接続dbdriverをチェックしているように、私はいくつかの提案を実装してみました(上記のコードスニペットで確認できます)。
どのような提案も高く評価されます!
しました。ありがとう! – dujmovicv