Error executing two procedures in Codeigniter

0

The problem is that in a controller I try to execute the two procedures I skip this error:

  

A Database Occurred Error

     

Error Number: 2014

     

Commands out of sync: you can not run this command now

     

CALL charges ();

     

Filename: models / Model_employees.php

     

Line Number: 56

My controller:

public function consulta(){
    $criterio=$this->input->post("criterio");
    $data["consulta"]=$this->Modelo_empleados->consultar($criterio);
    $data["puesto"]=$this->Modelo_empleados->cargos();
    $this->load->view("layout/header");
    $this->load->view("layout/menu");
    $this->load->view("layout/empleados",$data);
    $this->load->view("layout/footer");
}

The model:

public function consultar($dato){
    $con=$this->db->query("CALL consulta_empleado('$dato',@id,@nom,@ap,@am,@calle,@colonia,@localidad,@estado,@n_int,@n_ext,@cp,@tel,@email,@horario,@cargo);");
    return $con->result();
}
public function cargos(){
    $query=$this->db->query("CALL cargos();");
    return $query->result();
}
    
asked by Emmanuel 10.08.2017 в 04:21
source

1 answer

0

I will leave this solution here maybe it will help someone. If you are using codeigniter 3, put this code in the following path /system/database/drivers/mysqli/mysqli_driver.php

function free_db_resource()
{
    do
    {
        if($l_result = mysqli_store_result($this->conn_id))
        {
            mysqli_free_result($l_result);
        }
    }
    while(mysqli_more_results($this->conn_id)  && mysqli_next_result($this->conn_id));
}

then after each call you use the following code:

$ this- > db- > free_db_resource ();

    
answered by 07.09.2017 в 19:18