RoomsNumsReport.php
2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace common\models;
use Yii;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "{{%rooms_nums_report}}".
*
* @property integer $id
* @property integer $room_id
* @property integer $like_num
* @property integer $audience_num
* @property integer $online_num
* @property integer $replay_num
* @property integer $vest_online_num
* @property integer $create_time
*/
class RoomsNumsReport extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%rooms_nums_report}}';
}
/*public function behaviors()
{
return [
[
'class' => \yii\behaviors\TimestampBehavior::className(),
'createdAtAttribute' => 'create_time',
]
];
}*/
/**
* @inheritdoc
*/
public function rules()
{
return [
[['room_id', 'like_num', 'audience_num', 'online_num', 'replay_num', 'vest_online_num', 'create_time'], 'integer'],
[['create_time'], 'required'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'room_id' => 'Room ID',
'like_num' => 'Like Num',
'audience_num' => 'Audience Num',
'online_num' => 'Online Num',
'replay_num' => 'Replay Num',
'vest_online_num' => 'Vest Online Num',
'create_time' => 'Create Time',
];
}
/**
* 插入
* @param $parameters array 数据
* @return bool
*/
public function create($parameters)
{
$this->attributes = [
'room_id' => (int)$parameters['room'],
'like_num' => (int)$parameters['likeNums'],
'online_num' => (int)$parameters['onlineNums'],
'audience_num' => (int)$parameters['audienceNums'],
'vest_online_num' => (int)$parameters['vestOnlineNums'],
'create_time' => time()
];
return $this->save(false);
}
public static function condition($condtion)
{
$model = parent::find();
$filters = ArrayHelper::filter($condtion,['begin','end']);
if($filters['begin'] && $filters['end']){
$model->andWhere('create_time>='.strtotime($filters['begin']).' AND create_time<='.strtotime($filters['end']));
}
return $model;
}
}