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


PHP Posts::read方法代碼示例

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


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

示例1: begin

 public function begin()
 {
     $termId = $this->getParams('term_id');
     $ordering = $this->getParams('ordering');
     $fetchChild = $this->getParams('fetch_child', false);
     $q = Posts::read()->where('`status`=:status AND `is_draft` = 0')->setParameter(':status', 'PUBLISH', \PDO::PARAM_STR);
     $term = Terms::retrieveById($termId);
     if (!$term) {
         return;
     }
     if ($fetchChild) {
         $child = $term->getDescendants();
         $ids = array($term->getId());
         foreach ($child as $_c) {
             $ids[] = $_c->getId();
         }
         $q->andWhere('`term_id` IN (' . implode(',', $ids) . ')');
     } else {
         $q->andWhere('`term_id`=:term_id')->setParameter(':term_id', $term->getId(), \PDO::PARAM_INT);
     }
     //limit
     $limit = $this->getParams('limit');
     if ($limit) {
         $q->setMaxResults((int) $limit);
     }
     if ($ordering) {
         foreach ($ordering as $_ordering) {
             $q->addOrderBy($_ordering['field'], $_ordering['order']);
         }
     } else {
         $q->addOrderBy('modified_time', 'DESC');
     }
     $this->list = $q->execute()->fetchAll(\PDO::FETCH_CLASS, 'Posts', array(null, false));
 }
開發者ID:hosivan90,項目名稱:toxotes,代碼行數:34,代碼來源:LatestNews.php

示例2: Posts

                            <tr>
                                <th>Title</th>
                                <th>Author</th>
                                <th>Date</th>
                                <th>Views</th>
                                <th>Image</th>
                                <th>Count</th>
                                <th>Tag</th>
                                <th>Edit</th>
                                <th>Delete</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php 
$posts = new Posts($db);
$stmt = $posts->read();
while ($row = $stmt->fetch_assoc()) {
    echo "<tr></tr>";
    echo " <td>{$row['post_title']}</td>";
    echo " <td>{$row['post_author']}</td>";
    echo " <td>{$row['post_date']}</td>";
    echo " <td>{$row['post_views']}</td>";
    echo " <td>{$row['post_img']}</td>";
    echo " <td>{$row['post_coment_count']}</td>";
    echo " <td>{$row['post_tag']}</td>";
    echo " <td><a href='edit_posts.php?edit={$row['posts_id']}'><i class='fa fa-pencil-square-o'></i> Edit</a></td>";
    echo " <td><a href='post.php?delete={$row['posts_id']}' onclick='return confirm('Are you sure?') '><i class='fa fa-trash'></i> Delete</a></td>";
    echo "<tr></tr>";
}
?>
                                <?php 
開發者ID:TensaZangetsu,項目名稱:blog,代碼行數:31,代碼來源:posts.php

示例3: countPosts

 /**
  * @return int
  */
 public function countPosts()
 {
     return Posts::read()->where('`term_id` = ?')->count('id')->setParameter(1, $this->getId(), \PDO::PARAM_INT)->execute();
 }
開發者ID:hosivan90,項目名稱:toxotes,代碼行數:7,代碼來源:Terms.php


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