BiFace_Server_Lite/models/SyncUrl.php
2020-03-27 15:55:56 +07:00

57 lines
979 B
PHP

<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "sync_url".
*
* @property int $id
* @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'], 'string'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels() {
return [
'id' => 'ID',
'data' => 'Data',
];
}
public function create($data) {
$r = $this->load([
'data' => $data['url'],
], '');
if ($r) {
try {
$this->save();
return $this->id;
} catch (\Exception $ex) {
return false;
}
}
}
}