Hello. There is a task: to keep deletions and updates of records in all tables. The project is written in yii. DBMS: mysql. There are 8 tables. Content of one log:

[deleted / updated] an entry in the table [table_name] with values ​​(former) [field_name: value, ...]. Change author: [id_user]

What solutions can you offer?

This is what comes to my mind:
1. Triggers. But they disappear, because I can not get who the author of the changes, i.e. who is authorized - authorization is stored in the session.
2. The teacher failed to prove that this can be done through daily backups of the database and enable logging of all queries to the database to track what was happening with it. So it disappears.
3. It seems the most logical so far is to hang the behiwers on the yii model. In them, generate the desired row and write this row to the database table.
4. Just in every place of the code where something is deleted or updated to write a log. IMHO, ugly option.

Purpose: of course, minimal gestures and picking the code)

    1 answer 1

    3 option is quite suitable

    • @Ale_x, I thought so, but since I’m new to yii, php and mysql, then I thought maybe I don’t know something and someone would suggest more elegant and simple options. - Ray
    • I read about behavior in yii and a question arose. If the save () method is used to update and insert a record, how to write the behavoir for the update, not for adding the record? Or nothing? P.S. Asked a separate question. See my profile. - Ray