简体   繁体   中英

getting error in calling stored procedure

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.

Try to change database driver in your config from:

$db['default']['dbdriver'] = 'mysql';

to

$db['default']['dbdriver'] = 'mysqli';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM