<?php
/**
 * Created by PhpStorm.
 * User: xiaofeng
 * Date: 2018/3/4
 * Time: 上午9:25
 */

namespace common\models;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
class HouseClickrecord extends ActiveRecord
{

    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 FingByIp($ip,$hid)
    {
        return self::find()->andWhere(['ip'=>$ip])->andWhere(['hid'=>$hid])->exists();
    }
}