如何查看准备好的语句的内容? [英] How can I view the contents of a prepared statement?

查看:74
本文介绍了如何查看准备好的语句的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力学习在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.

这篇关于如何查看准备好的语句的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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