/** * 重载插入数据操作 * @param bool $insert */ protected function _beforeSave($insert) { parent::_beforeSave($insert); //插入前添加默认属性 if ($insert === true) { $this->setAttribute('create_time', \common\helpers\DateHelper::now()); $this->setAttribute('status', self::COMMENT_STATUS_OK); } }
/** * 重载插入数据操作 * @param bool $insert */ protected function _beforeSave($insert) { parent::_beforeSave($insert); //插入前添加默认属性 if ($insert === true) { $this->setAttribute('create_time', \common\helpers\DateHelper::now()); $this->setAttribute('act_status', self::ACT_STATUS_DRAFT); //设置_id } }