CI框架调用MySQL的存储过程,可以返回结果,但是不能渲染到模板。报错如下:
Error Number: 2014
Commands out of sync; you can't run this command now
这是什么原因呢?
代码如下:
$common = $this->db->query("call welcome_common_data($role_id)");
$data['head_data'] = $common->result_array()[0];
$this->view('/welcome/test',$data);
可能是你的存储过程返回多个结果集, 而只用了一个, 再请求时会报类似的错误
解决办法