How to get SQL statement in case of a dBException error

On the production page of my Yii 1.1 project I set up the error handling to get a mail message if an error occurs.

I want to add the SQL to the message content, if the error is a database related error.
How can I assign the SQL statement, that caused the error, to a PHP variable?

Tnank you for hints.

I am not sure there is a way but you might want to see what PDO provides as Yii just abstracts that. If it is possible there it should be possible here in some way.

I used Yii1 many years ago and have no idea currently

Thank you for ansering me.

I don’t need anymore to assign the SQL statement to a variable, because I can find the SQL statement, that caused an error in application.log

Sorry, that I had forgotten, that everything is logged in protected/runtime/application.log

1 Like