Blogger Information
Blog 25
fans 1
comment 1
visits 20679
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
larvel网站设置的保存--php中文网线上班
高的PHP十期培训学习笔记
Original
710 people have browsed it

setting.php 代码

  1. //保存
  2. public function save(Request $req)
  3. {
  4. $data['title'] = $req->title;
  5. $data['keywords'] = $req->keywords;
  6. $data['descs'] = $req->descs;
  7. if (!$data['title']){
  8. exit(json_encode(array('code'=>1,'msg'=>'网站名称不能为空')));
  9. }
  10. $item = DB::table('setting')->where('names','site_setting')->item();
  11. if ($item){
  12. DB::table('setting')->where('names','site_setting')->update(array('names'=>'site_setting','vals'=>json_encode($data)));
  13. }else{
  14. DB::table('setting')->insert(array('names'=>'site_setting','vals'=>json_encode($data)));
  15. }
  16. exit(json_encode(array('code'=>0,'msg'=>'保存成功')));
  17. }

网站设置的保存

用户权限菜单过滤

总结

网站设置的数据表’setting’的设计使用了键名和键值的设置方式,这样的设计方法的好处是可以把一些不经常使用更新的内容保存到自定义的键名当中;

Correcting teacher:WJWJ

Correction status:qualified

Teacher's comments:总体写的不错!
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments