예제 #1
0
 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));
 }
예제 #2
0
                            <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 
예제 #3
0
파일: Terms.php 프로젝트: hosivan90/toxotes
 /**
  * @return int
  */
 public function countPosts()
 {
     return Posts::read()->where('`term_id` = ?')->count('id')->setParameter(1, $this->getId(), \PDO::PARAM_INT)->execute();
 }