在调用存储过程时出错 [英] getting error in calling stored procedure

查看:269
本文介绍了在调用存储过程时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我运行这个模型程序没有存储过程调用意味着工作罚款。但如果我调用存储过程意味着抛出error.please帮助我我认为代表表名称的方式调用存储过程。



MODEL

 <?php if ('BASEPATH'))exit('不允许直接脚本访问); 

class Members_model extends CI_Model
{
function select_members()
{
$ query = $ this-> db-> get '); //表名
$ query = $ this-> db-> query(CALL get_members()); //调用存储过程
return $ query-> result_array();
}
}
?>

注意:抛出错误
发生数据库错误



 错误号码:2014 

命令不同步;你现在不能运行这个命令

UPDATE`users`SET`username` ='ThottiJaya',`password` ='28bf'WHERE`id` = 127

文件名:C:\ xampp\htdocs\system\database\DB_driver.php

行号:330


解决方案

根据MySQL:


5.2.14。命令不同步
如果您得到命令不同步;您现在无法在客户端代码中运行此命令,而是以错误的顺序调用客户端函数。



这可能会发生,例如,如果您使用mysql_use_result()并尝试在调用mysql_free_result()之前执行一个新的查询。如果您尝试执行两个查询返回数据而不调用之间的mysql_use_result()或mysql_store_result(),也可能发生这种情况。


我假设,在调用 update 之前,你有一些结果集打开,还没有使用。因此是错误。如果你和结果无关,你应该调用 mysql_free_result(),然后去更新

MySQL:命令不同步



参考类似文章

SO:为什么我得到错误命令不同步;您现在无法执行此命令






需要将您的mysql驱动程序更改为 mysqli



请参阅类似的帖子

SO:MySQL错误 - 命令不同步;您现在无法运行此命令



希望这有帮助。


if i run this model program without stored procedure calling means working fine.But if i calling stored procedure means throwing error.please help me i think the way of representing table name is wrong while calling stored procedure.

MODEL

 <?php if (!defined('BASEPATH')) exit('No direct script access allowed');

     class Members_model extends CI_Model 
     {       
         function select_members() 
         {           
             $query = $this->db->get('users'); //Table Name
             $query = $this->db->query("CALL get_members()");// calling stored procedure
             return $query->result_array();         
         }      
     }
?>

NOTE: Thrown Error A Database Error Occurred

Error Number: 2014

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

UPDATE `users` SET `username` = 'ThottiJaya', `password` = '28bf' WHERE `id` = 127

Filename: C:\xampp\htdocs\system\database\DB_driver.php

Line Number: 330

解决方案

As per MySQL:

C.5.2.14. Commands out of sync If you get Commands out of sync; you can't run this command now in your client code, you are > calling client functions in the wrong order.

This can happen, for example, if you are using mysql_use_result() and try to execute a new query before you have called mysql_free_result(). It can also happen if you try to execute two queries that return data without calling mysql_use_result() or mysql_store_result() in between.

I am assuming that, before making a call to update, you have some result set opened up and not used yet. And hence is the error. If you have nothing to do with the result, then you should be calling mysql_free_result() and then go for update call.

Refer To: MySQL: Commands out of sync

Refer To similar posts:
SO: Why I am getting the Error "Commands out of sync; you can't run this command now"


There is also a case where you need to change your mysql driver to mysqli.

Refer to similar post:
SO: MySQL Error - Commands out of sync; you can't run this command now

Hope this helps.

这篇关于在调用存储过程时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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