Beginners’ guide to stored procedures with MySQL?

I’ve Googled but come up with nothing that I can get my head around.

Are the performance gains from using stored procedures significant?

Would I still want to use prepared statements in conjunction with stored procs or is it generally a one or the other thing?

Can I create stored procs through PHPMyAdmin and manage them from there as well?

What would a stored procedure look like for something simple like this-

SELECT * FROM table a 
INNER JOIN otherTable b 
ON a.join_id=b.join_id 
WHERE someVar = :boundParam

and how would the PHP work (PDO) to call it and bind its parameter?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Consider this a gentle introduction to stored procedures in MySQL: http://www.mysqltutorial.org/mysql-stored-procedure-tutorial.aspx

You sure can create/manage stored procedures in phpMyAdmin.

Method 2

I have created one procedure but the time of call this procedure what parameter I can pass to get the output

CREATE DEFINER=`root`@`localhost` PROCEDURE `A`(

In user_id bigint,
Out address varchar(250)

)
BEGIN

select Address into address
from UserDetail_table
where User_ID = user_id; 

END


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x