How to use Stored Procedure in Laravel?

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.')' );

Popular posts from this blog

Ajax Toggle(on/off) on-click Update

Yii Framework In Update Time View Image In Form