命令不同步;您在Mysql中调用存储过程时不能运行此命令 [英] Commands out of sync; you can't run this command now while calling stored procedure in Mysql

查看:323
本文介绍了命令不同步;您在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 

可以任何1告诉我为什么我得到这个错误,如何摆脱。我使用代码点火器,我也试过这个

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().

我使用这个语句

   SELECT *
   FROM
  temp_calculated_rates_and_rules;
 -- and then
   TRUNCATE temp_calculated_rates_and_rules;

因为这个东西在PHP Loop中被调用,像这样

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

    }

p>

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();
}

我使用的是mysqli驱动程序

And i am using "mysqli" driver

推荐答案

因此,您需要处理由存储过程生成的额外结果集。 mysqli 驱动程序为此提供了一个方法,但是CodeIgniter可能不会使该方法可用。

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.

https://ellislab.com/forums/viewthread/73714/#562711


我只是添加以下到mysqli_result.php缺少
这个命令由于一些奇怪的原因。 (
/system/database/drivers/mysqli/mysqli_result.php下)

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

然后在我的模型中,我简单地调用$ result-> next_result()来释放
期望的额外结果集。

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

这篇关于命令不同步;您在Mysql中调用存储过程时不能运行此命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆