abstrak:<?php /** * Created by PhpStorm. * User: Administrator * Date: 2019-02-19 * Time: 下午 9:06 */ namespace app\admi
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2019-02-19 * Time: 下午 9:06 */ 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() { //通過id為1的獲得網(wǎng)站原始信息 $data = SystemModel::get(1); //將數(shù)據(jù)賦值到模板 $this->view->system=$data; //渲染系統(tǒng)列表 return $this->fetch(); } public function DoEdit() { //獲取數(shù)據(jù) $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'=>'保存失敗!']; } } }
Guru membetulkan:查無此人Masa pembetulan:2019-02-20 09:05:02
Rumusan guru:完成的不錯,后臺管理就是數(shù)據(jù)庫的增刪查改,多練習(xí),繼續(xù)加油。