ratamiette
(Ratamiette)
1
Hi all,
I use Yii::app()->db->createCommand()->insert() and Yii::app()->db->createCommand()->update() in some parts of my aplication.
I’d like to save a log in DB: which model and columns have been modified and the old value and the new value of the column.
How can I do this?
I know there are extensions as AuditTrail, but I don’t know if it works with Yii::app()->db->createCommand().
thank before.
hrnair
(Harikrishnan Hr)
2
Hi,
http://dev.mysql.com/doc/refman/5.7/en/binary-log-setting.html
in this you can use "STATEMENT" type
Also, you may have to uncommend the my.cnf file in the line where
log_bin=/location/of/log/file
ratamiette
(Ratamiette)
3
hrnair,
Thanks for answer.
Is there any way to do this by Yii?
hrnair
(Harikrishnan Hr)
4
Hi,
in your application configuration, there will be log component.
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
in the levels array, add ‘info’ and/or ‘trace’, and see if that will be ok for you. Yii provides these logs for you, which you can configure.