Calling stored procedure from codeigniter Calling stored procedure from codeigniter codeigniter codeigniter

Calling stored procedure from codeigniter


Stored procedures are invoked using the CALL procedure_name(optional_params) query.

You need to edit the query used in your model like this:

public function pc()    {        $query = $this->db->query("CALL pc()");        return $query->result();    }


Here is dude, This block of code work for me at model

function get_sunmeter_for_initiator($data){        try {            $this->db->reconnect();            $sql = "CALL `get_sunmeter_for_initiator`(?, ?, ?)";            $result = $this->db->query($sql,$data); // $data included 3 param and binding & query to db            $this->db->close();        } catch (Exception $e) {            echo $e->getMessage();        }        return $result;    }


You are using the following way to call procedure.

$this->db->call_function('pc');

Or you can also use this

$this->db->query("call pc()");