1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/7/12
- * Time: 下午2:43
- */
- namespace common\models;
- use yii\db\ActiveRecord;
- use yii\behaviors\TimestampBehavior;
- use Yii;
- class Syncrecord extends Common{
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::className(),
- 'attributes' => [
- # 创建之前
- ActiveRecord::EVENT_BEFORE_INSERT => ['create_at'],
- # 修改之前
- // ActiveRecord::EVENT_BEFORE_UPDATE => ['update_at']
- ],
- #设置默认值
- 'value' => $_SERVER['REQUEST_TIME']
- ]
- ];
- }
- protected function QueryFind()
- {
- return self::find();
- }
- public function FindByUnid($id)
- {
- return $this->QueryFind()->andWhere(['unid'=>$id])->orderBy(['create_at'=>SORT_DESC])->one();
- }
- public function Record($input)
- {
- $this->uid = $input['uid'];
- $this->hid = $input['hid'];
- $this->operation_type = $input['operation_type'];
- $this->content = $input['content'];
- $this->create_at = $_SERVER['REQUEST_TIME'];
- $this->unid = $input['unid'];
- return $this->save(false);
- }
- }
|