本文整理汇总了PHP中Posts::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::findAll方法的具体用法?PHP Posts::findAll怎么用?PHP Posts::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Posts
的用法示例。
在下文中一共展示了Posts::findAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* Lists all models.
*/
public function actionIndex()
{
$criteria = new CDbCriteria();
$criteria->order = 'cTime DESC';
//$criteria->select = 'id,title';
$model = new Posts();
$count = $model->count($criteria);
$pager = new CPagination($count);
$pager->pageSize = 100;
$pager->applyLimit($criteria);
$posts = $model->findAll($criteria);
$this->render('index', array('pages' => $pager, 'posts' => $posts));
}
示例2: searchKeyword
public static function searchKeyword($keyword)
{
$keyword = Helper::toRegularString($keyword);
//paging post
$model_post = new Posts();
$criteria = new CDbCriteria();
$criteria->condition = 'title like "%' . $keyword . '%" or content like "%' . $keyword . '%"';
$total = $model_post->count($criteria);
$pages = new CPagination($total);
$pages->pageSize = 4;
$pages->applyLimit($criteria);
$list = $model_post->findAll($criteria);
$posts_paging = array();
$posts_paging[] = $list;
$posts_paging[] = $pages;
return $posts_paging;
}