Answer the question
In order to leave comments, you need to log in
How to log SQL queries in Yii?
Good day. I need to log queries to the database for insert and update in certain parts of the application. I read about the standard Yii logging, I tried it - I was not impressed. Firstly, as I understand it, it is impossible to log not all requests, but only in certain places, and secondly, all this is logged in a form unsuitable for subsequent execution, and then I need to execute these requests in other databases. If someone understands the problem and wants to offer replication, then I don’t consider it because of the completely different server configuration.
The question is this: if I use AR, can I still achieve something that would log requests in the form
and in certain places, followed by writing to the database?
While I see only rewriting of all requests through QueryBuilder. I will be grateful for help. UPDATE table SET column = * WHERE id =1
Answer the question
In order to leave comments, you need to log in
You can write your own logger class (like LogTarget), set a category to log sql queries, manually filter out the necessary queries (for example, by entering instert / update), and log in the format you need, set it to reset the log immediately.
But are you sure that logging is the best option? Can all the same it is possible to solve your problem at the level of a DB? What kind of different configuration is this that prevents you from using replication or binlogs?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question