How to call a stored procedure in CodeIgniter?

前端 未结 2 444
南笙
南笙 2020-12-16 21:37

I can\'t call a stored procedure in CodeIgniter. However, when I call the procedure directly in MySQL, it works. Why isn\'t it working when I call it in CodeIgniter?

相关标签:
2条回答
  • 2020-12-16 22:07

    I think you are using the following way to call procedure.

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

    Its wrong. Only default procedures can be called using this method. To call procedures defined by you, you have to go with

    $this->db->query("call test_proc()");
    
    0 讨论(0)
  • 2020-12-16 22:10

    For Oracle procedured here is a simple way to call

     $rsponse = '';
        $s = oci_parse($this->db->conn_id, "begin packageName.procedureName(:bind1,:bind2,:bind3,:bind4,:bind5); end;");
                   oci_bind_by_name($s, ":bind1", $data['fieldOne'],300);
                   oci_bind_by_name($s, ":bind2", $data['fieldTwo'],300);
                   oci_bind_by_name($s, ":bind3", $data['fieldThre'],300);
                   oci_bind_by_name($s, ":bind4", $data['fieldFour'],300);
                   oci_bind_by_name($s, ":bind4", $response,300);
                   oci_execute($s, OCI_DEFAULT); 
    echo $message;
    

    In the above example procedure accept four arguments as input and one parameter as output. in case of direct calling procedure remove 'packageName.' That's it...

    0 讨论(0)
提交回复
热议问题