YII:Behavior

  1. 类型
  • CModelBehavior 的 events:
    • afterConstruct
    • beforeValidate
    • afterValidate
  • CActiveRecordBehavior 的 events:
    • beforeSave
    • afterSave
    • beforeDelete
    • afterDelete
    • beforeFind
    • afterFind
    • beforeCount
  1. 实例

CTimestampBehavior will automatically fill date and time related attributes when the active record is created and/or updated.You may specify an active record model to use this behavior like so:

public function behaviors(){
    return array(
        'CTimestampBehavior' => array(
            'class' => 'zii.behaviors.CTimestampBehavior',
            'createAttribute' => 'create_time_attribute',
            'updateAttribute' => 'update_time_attribute',
        )
    );
  }

你可能感兴趣的:(YII:Behavior)