BiFace_Server_Lite/models/WaitingReq.php
2020-09-23 09:52:39 +07:00

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' => json_encode($data),
'time' => time()
], '');
if ($r) {
try {
$this->save();
return $this->id;
} catch (\Exception $ex) {
return false;
}
}
}
}