123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/7/12
- * Time: 下午2:43
- */
- namespace common\models;
- use yii\db\ActiveRecord;
- use yii\behaviors\TimestampBehavior;
- class AllclickRecord 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']
- ]
- ];
- }
- public function RecordQuery($arr = [])
- {
- $query = self::find();
- $query->andWhere(['id'=>$arr['id']]);
- $query->andWhere(['ip'=>$arr['ip']]);
- $query->andWhere(['type'=>$arr['type']]);
- return $query->one();
- }
- public function addRecord($arr)
- {
- $this->id = $arr['id'];
- $this->ip = $arr['ip'];
- $this->type = $arr['type'];
- return $this->save();
- }
- }
|