我正在尝试运行一个过程,我得到了这个错误
Commands out of sync; you can't run this command now
这是我得到的原始错误
命令不同步;你现在不能运行这个命令
SELECT DISTINCT `property_id`, `pin`, `block_id`, `serial_no`, `status`, `ex_sn`, `ex_code`, `property_date_time`, `street_add`, `lab_name` FROM `view_property_user_lab` WHERE status = '6' AND lab_id = '01' AND designation IN( '5','6') LIMIT 10
任何一个能告诉我为什么会出现这个错误以及如何消除它吗。我正在使用代码点火器,我也尝试过这个
$query->free_result().
在我的程序中,我使用了这个语句
SELECT *
FROM
temp_calculated_rates_and_rules;
-- and then
TRUNCATE temp_calculated_rates_and_rules;
因为这个东西在PHP循环中被称为
$arrIds = array('5','10');
foreach ($arrIds as $id)
{
$this->_StoredProcedureMapper->setPId($id);
$p10values = $this->_StoredProcedureMapper->fetch_p10_values();
if (intval(@$p10values[0]['is_exempted']) != 1)
{
$this->generate_p10($p10values);
}
}
这是映射器函数
function fetch_p1_values()
{
$qry = "CALL sp_main_pt10(?)";
$result = $this->db->query($qry, $this->getPId());
return $result->result_array();
}
我使用的是"mysqli"驱动程序
因此,您需要处理存储过程生成的额外结果集。mysqli
驱动程序为此提供了一种方法,但CodeIgniter可能无法使用该方法。
发件人https://ellislab.com/forums/viewthread/73714/#562711:
我只是在mysqli_result.php中添加了缺少的以下内容这个命令是出于某种奇怪的原因。(在/system/database/drivers/mysqli/mysqli_result.php)
// -------------------------------------------------------------------- /** * Read the next result * * @return null */ function next_result() { if (is_object($this->conn_id)) { return mysqli_next_result($this->conn_id); } } // --------------------------------------------------------------------
然后在我的模型中,我简单地调用$result->next_result()来释放预期的无关结果集。