新增时间20240221
模板中的使用方法
controller/Updatesql.php
<?php
namespace 模板名\Controller;
use think\Controller;
use think\facade\Request;
use think\Db;
class Updatesql extends Controller
{
public function __construct ()
{
parent::__construct();
$this->tb_prefix = config()['database']['prefix'];
$this->site_version = strtolower(config()['version']['version']);
$this->version_arr = [
'v0.1'=>$this->v0_1(),
];
}
public function v0_1(){
$ret_data[1] = [
'tb_field_add',
"show columns from {$this->tb_prefix}post like 'etime'",
"alter table {$this->tb_prefix}post add etime int(11) not null default 0 comment '结束时间'",
];
return $ret_data;
}
public function update($sql_version="",$plugin_version="")
{
$up_arr = [];
foreach($this->version_arr as $k=>$vo){
if($k>$plugin_version){
break;
}
if($sql_version<$k){
$up_arr[$k] = $vo;
}
}
return $up_arr;
}
}
其他的sql使用方法可参考:http://zf-sys.wangmingchang.com/updatesql_show