MySQL 存储过程初学者指南?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4278392/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Beginners' guide to stored procedures with MySQL?
提问by bcmcfc
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?
我可以通过 PHPMyAdmin 创建存储过程并从那里管理它们吗?
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?
以及 PHP 如何工作 (PDO) 来调用它并绑定它的参数?
采纳答案by bcosca
Consider this a gentle introduction to stored procedures in MySQL: http://www.mysqltutorial.org/mysql-stored-procedure-tutorial.aspx
认为这是对 MySQL 中存储过程的温和介绍:http: //www.mysqltutorial.org/mysql-stored-procedure-tutorial.aspx
You sure can create/manage stored procedures in phpMyAdmin.
您肯定可以在 phpMyAdmin 中创建/管理存储过程。
回答by Ashish Seelwnai
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