How To Call Laravel Store Procedure Passing With Multipal Values In One Variable
I am using MS-SQL In My Laravel web site and I have create a SP which get result based on filter type It working fine when i Run The SP on MS-SQL ( http://prntscr.com/k70ta9 ) e.g : exec GetInventoryDetail @site='MI,SI' ( it return more then 100 Records )
Now the problem is when i send request by ajax it return zero result for "site" and "readyDate" In these two variables we have to pass more then two values like : 'MI,SI,DC' etc.
Please have a look on screen-short : http://prntscr.com/k70o7q
And My Function is which handle request is under given.
public function inventoryDetailData(Request $request){
try{
$vendorId = ($request->vendorId)? $request->vendorId : "";
$site = ($request->site)? $request->site : "";
$readyDate = ($request->readyDate)? $request->readyDate : "";
$filterArray = array($vendorId,$site,$readyDate);
$result = DB::select('exec GetInventoryDetail ?,?,?,', $filterArray);
dd($result);
}
catch(\Exception $e){
return response()->json(['status' => 'danger','message' => $e->getMessage()]);
}
This ajax functionality works fine for vendorId only but not for others.
Please help me how i can fix this issue. Is there any syntax problem in my code ?
Answer
I got Solution of my problem I use under given code and it work for me :)
DB::select(DB::raw("exec GetInventoryDetail :Param1, :Param2"),[
':Param1' => $param_1,
':Param2' => $param_2,
]);
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?