Like other implement ActiveRecord (AR) in many PHP n Ruby Framework, when I work with framework has implemeted it, there are some common method n there are some custom build-in from FW.
- Handle log changed (only changedAttributes)
in AR: $oldAttributes
getOldAttributes()
http://www.yiiframework.com/doc-2.0/yii-db-baseactiverecord.html
https://github.com/yiisoft/yii2/issues/4086
[5:31:19 PM] dzung nguyen: $log = 'test.txt';
$ln = "\r\n";
file_put_contents($log, $model->getOldAttributes(), FILE_APPEND);
[5:33:40 PM] dzung nguyen: n checkout logic in LogRecord::logAfterSave()
[5:33:58 PM] dzung nguyen: it calculate what field is need to log
- Handle log changed (only changedAttributes)
in AR: $oldAttributes
getOldAttributes()
http://www.yiiframework.com/doc-2.0/yii-db-baseactiverecord.html
https://github.com/yiisoft/yii2/issues/4086
[5:31:19 PM] dzung nguyen: $log = 'test.txt';
$ln = "\r\n";
file_put_contents($log, $model->getOldAttributes(), FILE_APPEND);
[5:33:40 PM] dzung nguyen: n checkout logic in LogRecord::logAfterSave()
[5:33:58 PM] dzung nguyen: it calculate what field is need to log
$rval = Yii::app()->db->createCommand()
ReplyDelete->select('u.*')
->from('user u')
->where('u.role_id = :role_id', array(':role_id' => '1'))
->queryAll();
User::model()->findByAttributes(array('role_id'=> '1'));