61 lines
1.1 KiB
PHP
61 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace app\models;
|
|
|
|
use Yii;
|
|
|
|
/**
|
|
* This is the model class for table "waiting_req".
|
|
*
|
|
* @property int $id
|
|
* @property string $content
|
|
* @property int $time
|
|
*/
|
|
class WaitingReq extends \yii\db\ActiveRecord {
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public static function tableName() {
|
|
return 'waiting_req';
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function rules() {
|
|
return [
|
|
[['content', 'time'], 'required'],
|
|
[['content'], 'string'],
|
|
[['time'], 'integer'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function attributeLabels() {
|
|
return [
|
|
'id' => 'ID',
|
|
'content' => 'Content',
|
|
'time' => 'Time',
|
|
];
|
|
}
|
|
|
|
public function create($data) {
|
|
$r = $this->load([
|
|
'content' => $data,
|
|
'time' => time()
|
|
], '');
|
|
if ($r) {
|
|
try {
|
|
$this->save();
|
|
return $this->id;
|
|
} catch (\Exception $ex) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|