Save createCommand() log

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.


in this you can use "STATEMENT" type

Also, you may have to uncommend the my.cnf file in the line where



Thanks for answer.

Is there any way to do this by Yii?


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.