从PDO准备语句获取查询

时间:2022-01-19 00:10:16

Is there a way to retrieve the query that was used to generate a PDO Prepared statement object?

是否有方法检索用于生成PDO准备语句对象的查询?

3 个解决方案

#1


32  

Try $statement->queryString.

尝试$声明- >查询字符串。

#2


9  

If you aren't opposed to extending the default \PDO and \PDOStatement object, you might consider looking at:

如果您不反对扩展默认的\PDO和\PDOStatement对象,您可以考虑查看:

github.com/noahheck/E_PDOStatement

github.com/noahheck/E_PDOStatement

This extension to PDO allows you to see a full query statement as an example of what might be executed at the database level. It uses regex to interpolate the bound parameters of your PDO statement.

PDO的这个扩展允许您看到完整的查询语句,作为在数据库级别执行的示例。它使用regex插入PDO语句的绑定参数。

By extending the default \PDOStatement definition, E_PDOStatement is able to offer this enhancement to the default functionality without requiring modification to your normal work flow.

通过扩展默认的\PDOStatement定义,E_PDOStatement可以在不需要修改正常工作流程的情况下为默认功能提供这种增强。

Disclaimer: I created this extension.

免责声明:我创建了这个扩展。

I just hope it's helpful to someone else.

我只是希望这对别人有帮助。

#3


0  

Self promotion: https://github.com/ellisgl/GeekLab-GLPDO You can output what's the expected query with the debug method. I've been updating it recently.

自我提升:https://github.com/ellisgl/GeekLab-GLPDO您可以使用调试方法输出预期的查询。我最近一直在更新。

#1


32  

Try $statement->queryString.

尝试$声明- >查询字符串。

#2


9  

If you aren't opposed to extending the default \PDO and \PDOStatement object, you might consider looking at:

如果您不反对扩展默认的\PDO和\PDOStatement对象,您可以考虑查看:

github.com/noahheck/E_PDOStatement

github.com/noahheck/E_PDOStatement

This extension to PDO allows you to see a full query statement as an example of what might be executed at the database level. It uses regex to interpolate the bound parameters of your PDO statement.

PDO的这个扩展允许您看到完整的查询语句,作为在数据库级别执行的示例。它使用regex插入PDO语句的绑定参数。

By extending the default \PDOStatement definition, E_PDOStatement is able to offer this enhancement to the default functionality without requiring modification to your normal work flow.

通过扩展默认的\PDOStatement定义,E_PDOStatement可以在不需要修改正常工作流程的情况下为默认功能提供这种增强。

Disclaimer: I created this extension.

免责声明:我创建了这个扩展。

I just hope it's helpful to someone else.

我只是希望这对别人有帮助。

#3


0  

Self promotion: https://github.com/ellisgl/GeekLab-GLPDO You can output what's the expected query with the debug method. I've been updating it recently.

自我提升:https://github.com/ellisgl/GeekLab-GLPDO您可以使用调试方法输出预期的查询。我最近一直在更新。