Search code examples
phpsql-serverlaravelstored-procedureslaravel-5

How to execute Stored Procedure from Laravel


I need to execute a stored procedure after my form submits data. I have the stored procedure working like I want it, and I have my form working properly. I just do not know the statement to execute the sp from laravel 5.

it should be something like this: execute my_stored_procedure. but I can not seem to find anything like that online.


Solution

  • Try something like this

    DB::select('exec my_stored_procedure("Param1", "param2",..)');
    

    or

    DB::select('exec my_stored_procedure(?,?,..)',array($Param1,$param2));
    

    Try this for without parameters

    DB::select('EXEC my_stored_procedure')