Is it possible in Yii2 to use save() without passing afterSave()?

In the basic model of the application you want to create log entries.
Decided to implement through the method aftersave() that the project was less code.
The problem is that when you save the log, it is stored in the database using the save() method.
How can I avoid this ? Or should I just using direct SQL query to save the entity logs in the database?
June 10th 19 at 15:51
2 answers
June 10th 19 at 15:53
it seems save(false) - save without validation and additional functions.
as a variant try the same update() .
June 10th 19 at 15:55
First, logging is a crosscutting functionality and to accommodate end-to-end functionality in the code model (afterSave) never true. It is better to make a separate behavior which will cling on event save the model and enter the required data in the database.
Secondly, why do You use model the log when logging? You in essence just need to generate the data and write them to the database and everything. There is no point in spending resource in the model is not using the functionality, so it is best to enter direct queries to the database.
I do not fit a direct request as I need after creating the log to find out the id of this log. As it then required me to realizovyvali functionality keeping logs for translatable fields. - Wilmer_Moo commented on June 10th 19 at 15:58
similarly , to find out the id of the log you can direct the query to the database. For example for mysql using LAST_INSERT_ID - bryana.Renn commented on June 10th 19 at 16:01

Find more questions by tags Yii