从 PHP 脚本中执行 MySQL 脚本? [英] Excute a MySQL script from within a PHP script?

查看:48
本文介绍了从 PHP 脚本中执行 MySQL 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以从 PHP 脚本 (bar.php) 中执行 MySQL 脚本 (foo.sql) 吗?如果是这样,如何?

Can you execute a MySQL script (foo.sql) from within a PHP script (bar.php)? If so, how?

而且,这是推荐还是不推荐的做法,为什么或为什么不推荐?

And, is this a recommended or not recommended practice, why or why not?

提前致谢.

推荐答案

怎么样?

bar.php:

<?php `mysql < foo.sql`;

请参阅执行运算符文档在批处理模式下使用 mysql文档.

这是推荐的 [...] 做法,为什么 [...] ?

is this a recommended [...] practice, why [...] ?

始终建议为工作选择合适的工具.mysql 命令行界面非常强大、快速且经过充分测试.它可以满足您的需求.

It's always recommended to choose the right tool for the job. the mysql commandline interface is pretty powerful, fast and well-tested. It does what you're looking for.

相关: 从 PHP 中加载 .sql 文件最佳实践:在 PHP 中导入 mySQL 文件;拆分查询.

这篇关于从 PHP 脚本中执行 MySQL 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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