• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MySQL, Querybuilder, Controller problems... ERR 2014

#1
Hello everyone,

I'm new to CI and haven't been into php for quite a while and now I'm stuck and don't get it to run. Tought it'd be an easy task, so in short:

Using a controller "Suppliers" which has a method "details", which will then call a view containing general details and a list of entries from another table. The view tells me that an error occured: 

Code:
Error Number: 2014

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

So to get the info needed:

My Controller
PHP Code:
class Suppliers extends CI_Controller {

 
       public function __construct()
 
       {
 
           parent::__construct();
 
           $this->load->model('suppliers_model');
 
           
            
            
//Check if logged in already
 
           session_valid();
 
       }

public function 
details($id NULL)
 
       {
 
           $data['supplier'] = $this->suppliers_model->get_supplier($id);
            if (empty($data['supplier'])) show_404();

            $data['certificates'] = $this->suppliers_model->get_supplier_certificates($id);


            $data['title'] = $this->lang->line('supplier'FALSE) . ': ' $data['supplier']['name'];

            $this->load->view('templates/header'$data);
            $this->load->view('suppliers/details'$data);
            $this->load->view('templates/footer');
 
       

My Model
PHP Code:
class Suppliers_model extends CI_Model {

 
       public function __construct()
 
       {
 
           $this->load->database();
 
       }

 
       public function get_suppliers($id FALSE)
 
       {
 
           if ($id === FALSE)
 
           {
 
               //$query = $this->db->get('suppliers');
 
               $query $this->db->query('call read_supplier_list()');
 
               return $query->result_array();
 
           }


 
           $query $this->db->query('call read_supplier(' $id ')');
 
           //$query = $this->db->get_where('suppliers', array('id' => $id));

 
           return $query->row_array();
 
       }

 
       public function get_supplier_certificates($supplier_id)
 
       {
 
           //$query = $this->db->query('call read_supplier_certificates(' . $supplier_id . ')');
 
           $query $this->db->get_where('supplier_certificates', array('supplier_id'$supplier_id));
 
           return $query->result_array();
 
       


So, pleasy tell me where I'm wrong... I dont' get it Sad
Reply

#2
I have never seen that error before.

A quick google gave me this: http://wikifixes.com/errors/b/0x/Error%2...ror%202014

So it seems that you have a system error that CI is running on. Something not installed correctly perhaps? Not much use I agree but I am guessing this is not a CI issue, but your local setup or a host environment problem.

Best wishes,

Paul
Reply

#3
Thanks for trying... at least I got around that error by not using stored procedures but CI-Querybuilder. Was not able to use a subquery this way, but it worked with grouping.
Reply

#4
http://stackoverflow.com/questions/88911...ommand-now
Keep calm.
Reply

#5
Try this and see if the error goes away.

PHP Code:
class Suppliers_model extends CI_Model {

    public function 
__construct()
    {
        
$this->load->database();
    }

    public function 
get_suppliers($id FALSE)
    {
        
$data = array();

        if (
$id === FALSE)
        {
            
//$query = $this->db->get('suppliers');
            
$query $this->db->query('call read_supplier_list()');
            
$data  $query->result_array();

            
$query->free_result();
            return 
$data;
        }

        
$query $this->db->query('call read_supplier(' $id ')');
        
//$query = $this->db->get_where('suppliers', array('id' => $id));

        
$data $query->row_array();
                
        
$query->free_result();
        return 
$data;
    }

    public function 
get_supplier_certificates($supplier_id)
    {
        
$data = array();
            
        
//$query = $this->db->query('call read_supplier_certificates(' . $supplier_id . ')');
        
$query $this->db->get_where('supplier_certificates', array('supplier_id'$supplier_id));
        
$data  $query->result_array();
                
        
$query->free_result();
        return 
$data;
    } 
What did you Try? What did you Get? What did you Expect?

Joined the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.