We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

how to log the low-level SQL statement with binding parameters?

with the document of phalcon->working with models->Logging Low-Level SQL Statements, I try to add an eventsManager of beforeQuery, to log the SQL statement with getSQLStatement.

But I use a binding parameter with find() method of a model. so in the log file which can't convert the bind parameters to actual value of parameter.

How can I solve this problem?

thanks!



24.1k
Accepted
answer

Hi

look here https://github.com/vpg/phalcon-debug-widget

It's a widget which listen for all requests.

I've added bindings parameter (https://github.com/vpg/phalcon-debug-widget/commit/694b58eafa01e5db3003c5f2aaf099dec29265c1) so that you can retrieve them



5.0k

thanks for your answer, I read your codes, it's excellent!! and I choose to use getSQLVariables() to get an array about the binding params.

Now I can get all the bind parmas in my log file!

Hi

look here https://github.com/vpg/phalcon-debug-widget

It's a widget which listen for all requests.

I've added bindings parameter (https://github.com/vpg/phalcon-debug-widget/commit/694b58eafa01e5db3003c5f2aaf099dec29265c1) so that you can retrieve them