如何使用phpmyadmin编写存储过程以及如何通过php使用? [英] How to write a stored procedure using phpmyadmin and how to use it through php?

查看:27
本文介绍了如何使用phpmyadmin编写存储过程以及如何通过php使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用 phpMyAdmin 创建存储过程,然后通过 php 使用它.

I want to be able create stored procedures using phpMyAdmin and later on use it through php.

据我所知,我发现我们无法通过 phpMyAdmin 管理存储过程.

From what I know, I found out that we cannot manage stored procedures through phpMyAdmin.

还有哪些工具可以管理存储过程?

我什至不确定通过 PHP 使用存储过程是否更好.有什么建议吗?

I am not even sure if it is better option to use stored procedure through PHP. Any suggestion?

推荐答案

由于使用查询创建、更改和删除存储过程,您实际上可以使用 phpMyAdmin 管理它们.

Since a stored procedure is created, altered and dropped using queries you actually CAN manage them using phpMyAdmin.

要创建存储过程,您可以使用以下内容(根据需要进行更改):

To create a stored procedure, you can use the following (change as necessary) :

CREATE PROCEDURE sp_test()
BEGIN
  SELECT 'Number of records: ', count(*) from test;
END//

并确保将 SQL 选项卡上的分隔符"字段设置为//.

And make sure you set the "Delimiter" field on the SQL tab to //.

一旦您创建了存储过程,它就会出现在您的表格下方的 Routines 字段集中(在 Structure 选项卡中),您可以轻松地更改/删除它.

Once you created the stored procedure it will appear in the Routines fieldset below your tables (in the Structure tab), and you can easily change/drop it.

要使用 PHP 中的存储过程,您必须执行 CALL 查询,就像在普通 SQL 中所做的一样.

To use the stored procedure from PHP you have to execute a CALL query, just like you would do in plain SQL.

这篇关于如何使用phpmyadmin编写存储过程以及如何通过php使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆