本文整理汇总了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));
}
示例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
示例3: countPosts
/**
* @return int
*/
public function countPosts()
{
return Posts::read()->where('`term_id` = ?')->count('id')->setParameter(1, $this->getId(), \PDO::PARAM_INT)->execute();
}