noo*_*php 5 php mysql stored-procedures codeigniter
我正在尝试运行一个程序,我收到此错误
Commands out of sync; you can't run this command now
Run Code Online (Sandbox Code Playgroud)
这是我得到的原始错误
命令不同步; 你现在不能运行这个命令
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
Run Code Online (Sandbox Code Playgroud)
可以任何1告诉我为什么我得到这个错误以及如何摆脱它.我正在使用Code igniter,我也试过这个
$query->free_result().
Run Code Online (Sandbox Code Playgroud)
在我的程序中,我使用了这个陈述
SELECT *
FROM
temp_calculated_rates_and_rules;
-- and then
TRUNCATE temp_calculated_rates_and_rules;
Run Code Online (Sandbox Code Playgroud)
因为这个东西在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);
}
}
Run Code Online (Sandbox Code Playgroud)
这是mapper函数
function fetch_p1_values()
{
$qry = "CALL sp_main_pt10(?)";
$result = $this->db->query($qry, $this->getPId());
return $result->result_array();
}
Run Code Online (Sandbox Code Playgroud)
而我正在使用"mysqli"驱动程序
所以你需要处理存储过程生成的额外结果集。驱动mysqli程序为此提供了一个方法,但 CodeIgniter 可能无法使该方法可用。
来自https://ellislab.com/forums/viewthread/73714/#562711:
我只是将以下内容添加到 mysqli_result.php 中,但由于某些奇怪的原因缺少此命令。(在/system/database/drivers/mysqli/mysqli_result.php下)
Run Code Online (Sandbox Code Playgroud)// -------------------------------------------------------------------- /** * 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() 即可释放预期的无关结果集。
| 归档时间: |
|
| 查看次数: |
8326 次 |
| 最近记录: |