PageController.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // +—————————————————————————————————————————————————————————————————————
  3. // | Created by Yunbao
  4. // +—————————————————————————————————————————————————————————————————————
  5. // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
  6. // +—————————————————————————————————————————————————————————————————————
  7. // | Author: https://gitee.com/yunbaokeji
  8. // +—————————————————————————————————————————————————————————————————————
  9. // | Date: 2022-04-30
  10. // +—————————————————————————————————————————————————————————————————————
  11. namespace app\appapi\controller;
  12. use cmf\controller\HomeBaseController;
  13. use think\Db;
  14. use think\db\Query;
  15. class PageController extends HomebaseController{
  16. //文章
  17. public function news() {
  18. $id = $this->request->param('id',0,'intval');
  19. $news=Db::name("posts")
  20. ->field("post_title,post_content")
  21. ->where("id='{$id}'")->find();
  22. $this->assign("news",$news);
  23. return $this->fetch();
  24. }
  25. //读取常见问题下的文章列表
  26. public function questions(){
  27. $questionList=Db::name("posts")
  28. ->field("id,post_title")
  29. ->where("termid=13")
  30. ->select();
  31. $questionList->all();
  32. $time=time();
  33. $this->assign("questionList",$questionList);
  34. $this->assign("time",$time);
  35. return $this->fetch();
  36. }
  37. }