Multiple Data Tables in PHP/MySQL?(PHP/MySQL中的多个数据表?)
问题描述
在 asp.net 中,您可以通过对数据库的一次调用来检索 MULTIPLE 数据表.你能在php中做同样的事情吗?
In asp.net, you can retrieve MULTIPLE datatables from a single call to the database. Can you do the same thing in php?
例子:
$sql ="select * from t1; select * from t2;";
$result = SomeQueryFunc($sql);
print_r($result[0]); // dump results for t1
print_r($result[1]); // dump results for t2
你可以这样做吗?
推荐答案
这叫做多查询".PHP 中的 mysql 扩展没有任何方法来启用多查询.mysqli 扩展确实允许您使用多查询,但只能通过 multi_query() 方法.请参阅 http://php.net/manual/en/mysqli.multi-query.php
This is called "multi-query." The mysql extension in PHP does not have any means to enable multi-query. The mysqli extension does allow you to use multi-query, but only through the multi_query() method. See http://php.net/manual/en/mysqli.multi-query.php
不推荐使用多查询,因为它会增加 SQL 注入攻击造成的潜在破坏.如果你使用多查询,你应该使用严格的代码检查习惯来避免SQL注入漏洞.
Using multi-query is not recommended, because it can increase the potential damage caused by SQL injection attacks. If you use multi-query, you should use rigorous code inspection habits to avoid SQL injection vulnerability.
这篇关于PHP/MySQL中的多个数据表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP/MySQL中的多个数据表?


基础教程推荐
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01