mysql pdo 实际执行的SQL语句怎么查看?

WBOY
Release: 2016-06-06 20:21:42
Original
1757 people have browsed it

看到PHP官网给了一个debugDumpParams();方法,但是并不能看到最终执行的语句啊,我想把最终执行的语句打出来然后复制到数据库里执行下

回复内容:

看到PHP官网给了一个debugDumpParams();方法,但是并不能看到最终执行的语句啊,我想把最终执行的语句打出来然后复制到数据库里执行下

PDO会预处理SQL语句,预处理的语句和普通的SQL查询执行的方式有所区别,简单的来说你可以把普通的SQL看成程序的源代码,预处理后的SQL看成编译后的程序,执行预处理后的SQL语句可以提高查询的效率,但也正是应为这些语句是处理过的(处理并不是简单将你的参数组装到SQL里去形成合成一个普通的SQL查询,而是分别传入查询信息和查询参数),所以你无法直观的看到以普通方式展现的SQL查询,就像你运行编译后的程序而由期望看到源代码一样。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!