Devmaurice's avatar

LAravel Mssql call procedures.

How do i call a procedure in mssql in laravel 5.2. what i have tried.

http://stackoverflow.com/questions/20666490/laravel-4-mssql-stored-procedure-with-parameters-as-a-prepared-statements

Am getting an empty array but when i ran in sql server with the same parameters i get data.

0 likes
3 replies
spekkionu's avatar

You might have to use the raw pdo connection

$pdo = DB::connection()->getPdo();
Iram's avatar

I'm try:

$llamadas = \DB::connection('sqlsrv')->getPdo()->query('exec spGetTopCall(?)',array($parametro));

But:

(1/1) PDOException SQLSTATE[IMSSP]: This function is not implemented by this driver.

If try: $data = \DB::connection('sqlsrv')->getPdo('exec spGetTopCall(?)',array($parameter));

Doesn't return the data

SOLVED: The parámeter should to be a DB RAW :

$data = \DB::connection('sqlsrv')->select('EXEC spGetTopCall ' . \DB::raw($parametro));

return response()->json(['data' => $data]);

Iram's avatar

Solution:

$data = \DB::connection('sqlsrv')->select('EXEC spGetTopCall ' . \DB::raw($parametro));

return response()->json(['data' => $data]);

1 like

Please or to participate in this conversation.