日期:2014-05-16 浏览次数:20516 次
$result = Yii::app()->db->createCommand($sql)->query();
$recorderCount = $result->rowCount;
$criteria = new CDbCriteria ();
$pages = new CPagination($result->rowCount);
$pages->pageSize =10;
$pages->applyLimit($criteria);
$result = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit");
$result->bindValue(':offset', $pages->currentPage * $pages->pageSize);
$result->bindValue(':limit', $pages->pageSize);
$posts = $result->query();
// render page.
$this->controller->render('index', array(
'posts' => $posts,
'pages' => $pages,
'recorderCount' => $recorderCount
));