mysql 不同步存储过程,命令不同步;您在Mysql中调用存储过程时不能运行此命令

I am trying to run a procedure i am getting this error

Commands out of sync; you can't run this command now

here is the original error that i get

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

can any 1 tell me why i am getting this error and how to get rid of it . I am using Code igniter and i also tried this

$query->free_result().

within my procedure i have used this statement

SELECT *

FROM

temp_calculated_rates_and_rules;

-- and then

TRUNCATE temp_calculated_rates_and_rules;

as this thing is called in PHP Loop which is like this

$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);

}

}

and here is mapper function

function fetch_p1_values()

{

$qry = "CALL sp_main_pt10(?)";

$result = $this->db->query($qry, $this->getPId());

return $result->result_array();

}

And i am using "mysqli" driver

解决方案

So you need to deal with the extra result sets generated by the stored procedure. The mysqli driver provides a method for this, but CodeIgniter may not make that method available.

I simply added the following into mysqli_result.php that is missing

this command for some strange reason. (under

/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);

}

}

// --------------------------------------------------------------------

Then in my model, I simply call $result->next_result() to loose the

expected extraneous resultset.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值