标签:tar schema this stat 知识 empty image getattr last
[[‘rId‘,‘advertiser_id‘,‘image_file‘], ‘unique‘,‘targetAttribute‘=>[‘rId‘,‘advertiser_id‘,‘image_file‘],‘message‘=>‘重复插入数据‘],//设置多个字段唯一
public static function getTableSchema() //设置字段的可变属性 { $schema = parent::getTableSchema(); $schema->columns[‘age‘]->phpType = ‘string‘; return $schema; }
public function behaviors() { return !empty($this->getDirtyAttributes())?[ //设置脏字段时最后更新时间变动 ‘timestamp‘ => [ ‘class‘ => TimestampBehavior::className(), ‘attributes‘ => [ ActiveRecord::EVENT_BEFORE_INSERT => [‘created_time‘, ‘last_modified_time‘], ActiveRecord::EVENT_BEFORE_UPDATE => ‘last_modified_time‘, ], ‘value‘ => function() { return date(‘Y-m-d H:i:s‘); }, ], ]:(parent::behaviors()); }
标签:tar schema this stat 知识 empty image getattr last
原文地址:http://www.cnblogs.com/isuben/p/6956176.html