1.

How to use Stored Procedure in Laravel?

Answer»

How to create a Stored PROCEDURE

To create a Stored Procedure you can execute given code in your MySQL query builder directly or use phpmyadmin for this.

DROP PROCEDURE IF EXISTS `get_subcategory_by_catid`;
delimiter ;;
CREATE PROCEDURE `get_subcategory_by_catid` (IN IDX int)
BEGIN
SELECT ID, parent_id, title, slug, created_at FROM category WHERE parent_id = idx AND status = 1 ORDER BY title;
END
;;
delimiter ;

After this, you can use this CREATED procedure in your code in Laravel.

How to use stored procedure in Laravel

$getSubCategories = DB::select(
   'CALL get_subcategory_by_catid('.$item->category_id.')'
);



Discussion

No Comment Found