时间:2021-07-01 10:21:17 帮助过:27人阅读
$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
));