简体   繁体   English

PHP MySql Mutliple在一个php文件中选择查询

[英]PHP MySql Mutliple select queries in one php file

I have a php file which I use to build a table. 我有一个php文件,可用来建立表格。 I am basically echoing out the html code... For the data, I am using multiple select queries. 我基本上是在回显html代码...对于数据,我正在使用多个选择查询。 The queries take the data in different tables... My question: Is it ok to run multiple select queries in one file? 查询将数据存储在不同的表中...我的问题:是否可以在一个文件中运行多个选择查询? For security purpose or else? 出于安全目的? Thank you in advance for your replies. 预先感谢您的答复。 Cheers. 干杯。 Marc. 渣。

There is no problem to run several queries from the same PHP script. 从同一PHP脚本运行多个查询没有问题。 Some advice: Work through the results once the query is sent and store information in a local data structure if needed. 一些建议:发送查询后检查结果,并在需要时将信息存储在本地数据结构中。 That way resources can be freed quickly. 这样就可以快速释放资源。 Even better would be to join the queries if possible because each database call costs a lot of time. 如果可能的话,最好加入查询,因为每个数据库调用花费大量时间。

Security concerns should be same for multiple queries and a single query. 对于多个查询和单个查询,安全性问题应该相同。 On the other hand, when it comes to mysql queries you should concern about performance. 另一方面,在涉及mysql查询时,您应该关注性能。 You may combine that seperate queries in one query and that way you can gain performance for avoiding sending multiple requests seperatly. 您可以将多个单独的查询合并到一个查询中,这样就可以避免避免单独发送多个请求,从而提高性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM