Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call stored procedure on Laravel?

Tags:

php

laravel-5

Error comes when i run update stored procedure in laravel5 like this..

QueryException in Connection.php line 620: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Sandeep,09999999999,,,[email protected],,,,,,,)' at line 1 (SQL: call sp_clientupdate(108, Sandeep,09999999999,,,[email protected],,,,,,,))

my code is....

return DB::select('call sp_clientupdate(108, Sandeep,0999999999,,,[email protected],,,,,,,)');

Pls anyone give me solution.....

like image 649
Software Engineer Avatar asked May 28 '15 05:05

Software Engineer


People also ask

How do you call a stored procedure?

You can call an SQL stored procedure with the execute, open, or get statement; in each case, you use the #sql directive. A stored procedure is a set of instructions for a database, like a function in EGL.

How can I call stored procedure in PHP?

To call a stored procedure from a PHP application, you prepare and execute an SQL CALL statement. The procedure that you call can include input parameters (IN), output parameters (OUT), and input and output parameters (INOUT).

What is stored procedure in laravel?

Stored procedures are handy for encapsulating database intensive operations. Consider Stored Procedures as an API for your database. Laravel models are often one-to-one representations of a database table. So, they don't support stored procedures out of the box.


2 Answers

Try this one,

DB::statement('call sp_clientupdate("108", "Sandeep","0999999999","","","[email protected]","","","","","","",)');

It works perfectly.

like image 114
Tonmoy Nandy Avatar answered Oct 23 '22 11:10

Tonmoy Nandy


You change.

return DB::select('call sp_clientupdate("108", "Sandeep","0999999999","","","[email protected]","","","","","","",)');

Try it's working perfectly....

like image 36
Prashant Patel Avatar answered Oct 23 '22 11:10

Prashant Patel