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