public function testRedis() { error_reporting(0); //require 'ThinkPHP\Library\Think\Cache\Driver\Redis.class.php'; $test = new ArticleModel(); $test->insert2Redis(); }
public function college() { $Article = new ArticleModel(); $college = $Article->getCollege(); $this->assign('college', $college[0]); $this->display(); }
public function index() { $ip = $_SERVER["REMOTE_ADDR"]; $now = date("Y-m-d H:i:s", time()); $less_minute_time = date("Y-m-d H:i:s", time() - 60); $visitor = M('Visitors'); $res = $visitor->where('ip_address="' . $ip . '" AND visit_start_at >="' . $less_minute_time . '"')->find(); if (!$res) { $sum = M('sums'); $total = $sum->where('id=1')->getField('visitor_sum'); $visitor->add(array('ip_address' => $ip, 'visit_start_at' => $now, 'created_at' => $now)); $data['visitor_sum'] = $total + 1; $sum->where('id=1')->save($data); } $article = new Article(); $count = $article->order('updated_at desc')->count(); // 查询满足要求的总记录数 $Page = new \Think\Page($count, 3); // 实例化分页类 传入总记录数和每页显示的记录数(25) $Page->setConfig('header', '页'); $Page->setConfig('prev', ''); $Page->setConfig('next', ''); $Page->setConfig('first', '>>'); $Page->setConfig('end', '<<'); $show = $Page->show(); // 分页显示输出 // 进行分页数据查询 注意limit方法的参数要使用Page类的属性 $list = $article->order('updated_at desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); $this->assign('articles', $list); // 赋值数据集 $this->assign('page', $show); // 赋值分页输出 $this->display('index'); // 输出模板 }
public function positionCenter() { $Article = new ArticleModel(); $jobs = $Article->getJobs(0); $this->assign('jobs', $jobs); $this->display(); }
public function article() { $id = $_GET['id']; $Article = new ArticleModel(); $article = $Article->getAnnouncement($id); $this->assign('article', $article[0]); $this->display(); }
public function index() { $map = array(); $title = $author = $article_type = $updated_at_start = $updated_at_end = ''; $title = $_GET['title']; if ($title != null) { $map['title'] = array('like', "%{$title}%"); } $author = $_GET['author']; if ($author != null) { $map['author'] = array('like', "%{$author}%"); } $article_type = $_GET['article_type']; if ($article_type != null) { $map['article_type'] = array('eq', $article_type); } $updated_at_start = $_GET['updated_at_start']; if ($updated_at_start != null) { $map['updated_at'] = array('egt', $updated_at_start); } $updated_at_end = $_GET['updated_at_end']; if ($updated_at_end != null) { $map['updated_at'] = array('elt', $updated_at_end); } if ($updated_at_start != null && $updated_at_end != null) { $map['updated_at'] = array('between', array($updated_at_start, $updated_at_end)); } $this->assign('title', $title); $this->assign('author', $author); $this->assign('article_type', $article_type); $this->assign('updated_at_start', $updated_at_start); $this->assign('updated_at_end', $updated_at_end); $article = new \Home\Model\ArticleModel(); $count = $article->where($map)->order('updated_at desc')->count(); // 查询满足要求的总记录数 $Page = new \Think\Page($count, 10); // 实例化分页类 传入总记录数和每页显示的记录数(25) $Page->setConfig('header', '页'); $Page->setConfig('prev', ''); $Page->setConfig('next', ''); $Page->setConfig('first', '>>'); $Page->setConfig('end', '<<'); $show = $Page->show(); // 分页显示输出 // 进行分页数据查询 注意limit方法的参数要使用Page类的属性 $list = $article->where($map)->order('updated_at desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); $this->assign('articles', $list); // 赋值数据集 $this->assign('page', $show); // 赋值分页输出 $this->assign('article_types', ArticleLib::$ARTICLE_TYPE); $this->display('index'); // 输出模板 }
public function index() { $Article = new ArticleModel(); $Slide = new SlideModel(); $slides = $Slide->getSlides(); $announcements = $Article->getAnnouncements(3); $this->assign('announcements', $announcements); $this->assign('slides', $slides); $jobs = $Article->getJobs(4); $this->assign('jobs', $jobs); $this->display(); }
public function showArticleFeilei($name) { $article = new Article(); $count = $article->where('article_type="' . $name . '"')->count(); // 查询满足要求的总记录数 $Page = new \Think\Page($count, 3); // 实例化分页类 传入总记录数和每页显示的记录数(25) $Page->setConfig('header', '页'); $Page->setConfig('prev', ''); $Page->setConfig('next', ''); $Page->setConfig('first', '>>'); $Page->setConfig('end', '<<'); $show = $Page->show(); // 分页显示输出 // 进行分页数据查询 注意limit方法的参数要使用Page类的属性 $list = $article->where('article_type="' . $name . '"')->order('updated_at desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); $this->assign('articles', $list); // 赋值数据集 $this->assign('page', $show); // 赋值分页输出 $this->display('Index/index'); // 输出模板 }
/** *动作: 后台展示一篇文章 **/ public function show($id) { $articles = new Article(); $article = $articles->where('id=' . $id)->find(); $comments = $articles->relation(true)->find($id); $this->assign('article', $article); $this->assign('comments', $comments['comment']); $this->display('show'); }
public function selectTest() { $articleID = '1'; $selectData = new ArticleModel(); dump($selectData->selectArticle($articleID)); }