<?php
namespace
app\admin\controller;
use
app\admin\controller\Common;
use
app\admin\model\SystemModel;
use
think\facade\Request;
use
think\facade\Session;
class
System
extends
Common
{
public
function
index()
{
$data
= SystemModel::get(1);
$this
->view->system =
$data
;
return
$this
->fetch();
}
public
function
DoEdit()
{
$data
= Request::param();
$system
=
new
SystemModel();
$info
=
$system
->save([
'site_name'
=>
$data
[
'site_name'
],
'about_title'
=>
$data
[
'about_title'
],
'about_content'
=>
$data
[
'about_content'
],
'ci_title'
=>
$data
[
'ci_title'
],
'ci_content'
=>
$data
[
'ci_content'
],
'cp_title'
=>
$data
[
'cp_title'
],
'cp_content'
=>
$data
[
'cp_content'
],
],[
'id'
=>1]);
if
(
$info
){
return
[
'res'
=>1,
'msg'
=>
'更新成功'
];
}
else
{
return
[
'res'
=>0,
'msg'
=>
'更新失败'
];
}
}
}
顺序:1、创建控制器;2,创建显示界面;3、根据界面参数创建数据库结构;4、创建模型用来通过控制器操作数据库