當前位置: 首頁>>代碼示例>>PHP>>正文


PHP post::findAll方法代碼示例

本文整理匯總了PHP中post::findAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP post::findAll方法的具體用法?PHP post::findAll怎麽用?PHP post::findAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在post的用法示例。


在下文中一共展示了post::findAll方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getPosts

 public function getPosts($status = null, $limitQuery = null)
 {
     $P = new post();
     $posts = array();
     if (is_null($status) === true) {
         $posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, null);
     } else {
         if (is_array($status) === false) {
             $posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, "WHERE status='{$status}'");
         } else {
             $status_sql = "";
             foreach ($status as $st) {
                 $status_sql .= "status ='{$st}' OR ";
             }
             $status_sql = substr($status_sql, 0, -3);
             $posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, "WHERE ({$status_sql})");
         }
     }
     $C = new comment();
     foreach ($posts as $k => $p) {
         $posts[$k]['title'] = htmlspecialchars($posts[$k]['title']);
         $posts[$k]['tags'] = $this->getTags($posts[$k]['ID']);
         $posts[$k]['comments_count'] = $C->countCommentsByPost($posts[$k]['ID'], "publish");
         $U = new user();
         if ($posts[$k]['id_user'] < 2) {
             $posts[$k]['autor'] = $U->find(1);
         } else {
             $posts[$k]['autor'] = $U->find($posts[$k]['id_user']);
         }
     }
     return $posts;
 }
開發者ID:ravenlp,項目名稱:CodiceCMS,代碼行數:32,代碼來源:post.php

示例2: rss

 public function rss($id = NULL)
 {
     $this->plugin->call('feed_header');
     $post = new post();
     $this->view->conf = $this->conf;
     $this->view->setLayout("feed");
     $posts = $post->findAll("ID,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", "ID DESC", $this->conf['blog_posts_per_page'], "WHERE status = 'publish'");
     $temp = array();
     foreach ($posts as $a_post) {
         $temp[$a_post['ID']] = $a_post;
         $temp[$a_post['ID']]['tags'] = $post->getTags($a_post['ID'], 'string');
     }
     $this->view->posts = $temp;
     $this->render("rss");
 }
開發者ID:ravenlp,項目名稱:CodiceCMS,代碼行數:15,代碼來源:feed_controller.php

示例3: index

 public function index($id = NULL)
 {
     $P = new post();
     $total_rows = $P->countPosts();
     $page = $id;
     $page = is_null($page) ? 1 : $page;
     $limit = $this->userConf['posts_per_page'];
     $offset = ($page - 1) * $limit;
     $limitQuery = $offset . "," . $limit;
     $targetpage = $this->path . 'admin/index/';
     $pagination = $this->pagination->init($total_rows, $page, $limit, $targetpage);
     $this->title_for_layout("Administraci&oacute;n - Codice CMS");
     $this->view->pagination = $pagination;
     $this->view->posts = $P->findAll(NULL, "ID DESC", $limitQuery, NULL);
     $this->view->blogConfig = $this->blogConfig;
     $this->view->userConf = $this->userConf;
     $this->view->setLayout("admin");
     $this->render();
 }
開發者ID:ravenlp,項目名稱:CodiceCMS,代碼行數:19,代碼來源:admin_controller.php


注:本文中的post::findAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。