Calling a stored procedure from CodeIgniter's Active Record class

后端 未结 6 493
旧时难觅i
旧时难觅i 2020-12-05 17:09

In my CI application setup to query a mssql database. I want to execute a stored procedure from active record. But I

6条回答
  •  星月不相逢
    2020-12-05 17:47

    If you are using later versions of codeigniter with mssql or sqlsrv with stored procedures, using 'CALL' as in query('CALL procedureName($param1,$params,....)') may not work.

    In the case of MSSQL use:

    $this->db->query('EXEC procedureName')
    

    OR

    $this->db->query('EXEC procedureName $param1 $param2 $param3,...')
    

    In some cases you might need to turn on some constants for the driver. In this case run:

    $this->db->query('Set MSSQL constant ON )
    

    before running your regular query.

提交回复
热议问题