How to use Stored Procedures in Laravel

0 votes
How to create a Stored Procedure? Can Anyone explain me out there??
Mar 24, 2020 in Laravel by kartik
• 37,520 points
4,922 views

1 answer to this question.

0 votes

Hey,

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

Thank you!!

answered Mar 24, 2020 by Niroj
• 82,880 points

Related Questions In Laravel

0 votes
1 answer

How to use multiple databases in Laravel?

Hello @kartik, Laravel has inbuilt support for multiple ...READ MORE

answered Jul 30, 2020 in Laravel by Niroj
• 82,880 points
2,302 views
0 votes
1 answer

How to use API Routes in Laravel?

Hello @kartik, You call it by http://localhost:8080/api/test ...READ MORE

answered Aug 10, 2020 in Laravel by Niroj
• 82,880 points
7,692 views
0 votes
1 answer

How to only use created_at in Laravel?

Hello @kartik, Eloquent does not provide such functionality ...READ MORE

answered Aug 11, 2020 in Laravel by Niroj
• 82,880 points
2,931 views
0 votes
1 answer

How to use GROUP_CONCAT in laravel?

Hello @kartik, You can use relations as query ...READ MORE

answered Sep 25, 2020 in Laravel by Niroj
• 82,880 points
7,551 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
22,855 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
2,924 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,880 points
2,861 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,880 points
44,144 views
0 votes
1 answer

How to use mail() in laravel?

Hello, Laravel provides a powerful and clean API ...READ MORE

answered Mar 24, 2020 in Laravel by Niroj
• 82,880 points
879 views
0 votes
1 answer

How to make a constant and use globally in laravel?

Hii, You can create a constants.php page in config folder ...READ MORE

answered Mar 24, 2020 in Laravel by Niroj
• 82,880 points
3,988 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP