问题描述
我正在努力学习在PHP中使用带有mysqli的准备好的语句,通常,如果我对查询有疑问,我只是将其回显到屏幕上,以查看第一步的样子.
I'm working on learning to use prepared statements with mysqli in PHP and usually, if I'm having a problem with a query I just echo it to the screen to see what it looks like as a first step.
如何用准备好的陈述来做到这一点?
How can I do that with a prepared statement?
在替换变量后,我想查看SQL语句.
I'd like to see the SQL statement after the variables are substituted.
推荐答案
使用准备好的语句:
- 准备该语句时,它会发送到MySQL服务器
- 绑定变量+执行语句时,仅将变量发送到MySQL服务器
- 并且语句+绑定变量在MySQL服务器上执行-无需在每次执行语句时都重新执行准备工作"(这就是为什么当同一条语句时,准备好的语句可以提高性能的原因)被执行了几次)
PHP端没有构建" SQL查询的功能,因此,实际上无法获得该查询.
There is no "building" of an SQL query on the PHP side, so, there is no way to actually get that query.
这意味着,如果要查看SQL查询,则必须使用SQL查询,而不要使用准备好的语句.
Which means that if you want to see an SQL query, you have to use, well, SQL queries, and not prepared statements.
这篇关于如何查看准备好的语句的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!