本文整理汇总了PHP中CPagination::getLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP CPagination::getLimit方法的具体用法?PHP CPagination::getLimit怎么用?PHP CPagination::getLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPagination
的用法示例。
在下文中一共展示了CPagination::getLimit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Pages
/**
*
* Enter description here ...
* @param unknown_type $params
*/
public static function Pages($params = array())
{
//设置默认参数
$_defaults_params = array('allow_cache' => true, 'page' => isset($_GET['page']) ? intval($_GET['page']) : 1, 'pagesize' => 30);
$params = array_merge($_defaults_params, $params);
$cmd = Yii::app()->db->createCommand();
$cmd->select('COUNT(u.collect_log_id) AS COUNT')->from('{{collect_log}} u');
if (intval($params['collect_log_insert_time'])) {
$__addons = array('AND', 'u.collect_log_insert_time=:collect_log_insert_time');
$__params = array(':collect_log_insert_time' => $params['collect_log_insert_time']);
}
if ($params['collect_log_msg']) {
$__addons[] = array('AND', array('OR LIKE', 'u.collect_log_msg', "%{$params[collect_log_msg]}%"));
}
if (is_array($__addons) && is_array($__params)) {
$cmd->where($__addons, $__params);
}
//统计数量
$count = $cmd->queryScalar();
//分页处理
$pages = new CPagination($count);
//设置分页大小
$pages->pageSize = $params['pagesize'];
//清空前面执行过的SQL
$cmd->setText('');
if (isset($params['orderby']) && $params['orderby']) {
$cmd->order($params['orderby']);
} else {
$cmd->order(array('u.collect_log_id DESC'));
}
$cmd->select('u.*')->limit($pages->getLimit())->offset($pages->getOffset());
$_r['pages'] = $pages;
$_r['rows'] = $cmd->queryAll();
return $_r;
}
示例2: fetchAllByPage
public function fetchAllByPage($conditions = "", $pageSize = null)
{
$pages = new CPagination($this->countByCondition($conditions));
$pageSize = is_null($pageSize) ? Yii::app()->params["basePerPage"] : $pageSize;
$pages->setPageSize(intval($pageSize));
$criteria = new CDbCriteria(array("limit" => $pages->getLimit(), "offset" => $pages->getOffset()));
$pages->applyLimit($criteria);
$fields = "r.resumeid,rd.detailid,rd.realname,rd.positionid,rd.gender,rd.birthday,rd.education,rd.workyears,r.flag,r.status";
$sql = "SELECT {$fields} FROM {{resume}} r LEFT JOIN {{resume_detail}} rd ON r.resumeid=rd.resumeid ";
if (!empty($conditions)) {
$sql .= " WHERE " . $conditions;
}
$offset = $pages->getOffset();
$limit = $pages->getLimit();
$sql .= " ORDER BY r.entrytime DESC LIMIT {$offset},{$limit}";
$records = $this->getDbConnection()->createCommand($sql)->queryAll();
return array("pages" => $pages, "datas" => $records);
}
示例3: search
public function search($begin, $end)
{
$condition = 'time>=:begin AND time<=:end';
$params = ['begin' => $begin, 'end' => $end];
$model = Logging::model();
$pager = new CPagination($model->count($condition, $params));
$pager->setPageSize(100);
$logging = $model->findAll(['condition' => $condition, 'params' => $params, 'offset' => $pager->getOffset(), 'limit' => $pager->getLimit(), 'order' => 'time desc']);
$this->render('index', ['logging' => new RedArrayDataProvider($logging), 'pager' => $pager]);
}
示例4: actionView
/**
* Displays a particular model.
*
* @param integer $id
* the ID of the model to be displayed
*/
public function actionView($id)
{
$count = CopyrightInputContentModel::model()->getCountSong($id);
$page = new CPagination($count);
$page->pageSize = 100;
$songs = CopyrightInputContentModel::model()->getListSong($id, $page->getLimit(), $page->getOffset());
/* $inputModel = new CopyrightSongInputModel("search");
$inputModel->unsetAttributes ();
$inputModel->setAttribute("input_file", $id); */
$this->render('view', array('model' => $this->loadModel($id), 'songs' => $songs, 'page' => $page));
}
示例5: view
private function view()
{
$query = $this->request->getPost('Setting', []);
$model = Setting::model();
$model->attributes = $query;
$condition = $this->createSearchCriteria($query);
$pager = new CPagination($model->count($condition));
$pager->setPageSize(20);
$condition['offset'] = $pager->getOffset();
$condition['limit'] = $pager->getLimit();
$data = $model->findAll($condition);
$this->render('setting', ['data' => new RedArrayDataProvider($data), 'pager' => $pager, 'model' => $model]);
}
示例6: run
public function run()
{
$query = $this->request->getQuery('Service', []);
$model = Service::model();
$model->attributes = $query;
$condition = $this->createSearchCriteria($query);
$pager = new CPagination($model->count($condition));
$pager->setPageSize(20);
$condition['offset'] = $pager->getOffset();
$condition['limit'] = $pager->getLimit();
$condition['order'] = 'status asc, uid asc';
$data = $model->findAll($condition);
$this->render('pac', ['data' => new RedArrayDataProvider($data), 'pager' => $pager, 'model' => $model]);
}
示例7: actionIndex
public function actionIndex()
{
$c = array('conditions' => array('status' => array('==' => 1)));
$total = WebArticlesModel::model()->count($c);
$pager = new CPagination($total);
$itemOnPaging = 5;
$pager->pageSize = 10;
$curr_page = $pager->getCurrentPage();
$limit = $pager->getLimit();
$offset = $pager->getOffset();
$c = array('conditions' => array('status' => array('==' => 1)), 'sort' => array('_id' => EMongoCriteria::SORT_DESC), 'limit' => $limit, 'offset' => $offset);
$data = FeedModel::model()->findAll($c);
$this->render('index', compact('data', 'pager', 'itemOnPaging'));
}
示例8: actionBilling
public function actionBilling()
{
$query = ['uid' => $this->user->getId()];
$model = Traffic::model();
$model->attributes = $query;
$condition = ['condition' => 'uid=:uid', 'params' => ['uid' => $query['uid']]];
$pager = new CPagination($model->count($condition));
$pager->setPageSize(20);
$condition['offset'] = $pager->getOffset();
$condition['limit'] = $pager->getLimit();
$condition['order'] = 'date desc';
$data = $model->findAll($condition);
$this->render('billing', ['data' => new RedArrayDataProvider($data), 'pager' => $pager]);
}
示例9: actionSearch
public function actionSearch()
{
$keyword = Yii::app()->request->getParam('q');
if ($keyword == '') {
$this->redirect(Yii::app()->homeUrl);
}
$keyword = Common::RemoveXSS($keyword);
$order = Yii::app()->request->getParam('order', 1);
$channel = strtolower(Yii::app()->request->getParam('channel', 'web'));
$pagesize = 12;
$count = ProductModel::model()->countsearchProduct($channel, $keyword);
$page = new CPagination($count);
$page->pageSize = $pagesize;
$product_web = ProductModel::model()->searchProduct($channel, $keyword, $order, $page->getLimit(), $page->getOffset());
$this->render('search', compact('product_web', 'page', 'keyword', 'order', 'channel', 'count'));
}
示例10: actionList
public function actionList()
{
$limit = Yii::app()->params['numberPerPage'];
$c = CHtml::encode(Yii::app()->request->getParam('id', '0'));
$c = (int) (!empty($c)) ? $c : '0';
$s = CHtml::encode(Yii::app()->request->getParam('type'));
$s = !empty($s) ? $s : Yii::t('wap', 'Hot');
$s = strtoupper($s);
$cTitle = $c == 0 ? Yii::t('wap', 'All genres') : WapGenreModel::model()->findByPk($c)->name;
$sTitle = $s == 'NEW' ? Yii::t('wap', 'New') : $s;
$page = (int) Yii::app()->request->getParam('page', 1);
$callBack = (int) Yii::app()->request->getParam('call_back', 0);
$callBackLink = Yii::app()->createUrl("album/list", array('type' => $c, 's' => $s, 'c' => $c));
$options = array();
if ($c == 0) {
if ($s == 'NEW') {
$count = WapAlbumModel::countListByCollection('ALBUM_NEW');
$albums = WapAlbumModel::getListNew($page, $limit);
$options = array('col' => 'ALBUM_NEW', 'headerText' => "ALBUM MỚI");
} else {
$options = array('col' => 'ALBUM_HOT', 'headerText' => "ALBUM HOT");
$albums = WapAlbumModel::getListHot($page, $limit);
$count = WapAlbumModel::countListByCollection('ALBUM_HOT');
}
$pager = new CPagination($count);
$pager->setPageSize($limit);
} else {
if ($s == 'NEW') {
$count = WapAlbumModel::model()->countAlbumsByGenre($c);
$pager = new CPagination($count);
$pager->setPageSize($limit);
$albums = WapAlbumModel::model()->getAlbumsByGenre($c, $pager->getOffset(), $pager->getLimit());
} else {
$count = WapGenreModel::getCountAlbumsByGenreCollection($c);
$pager = new CPagination($count);
$pager->setPageSize($limit);
$id_album_hot = 6;
$albums = WapGenreModel::getAlbumsByGenreCollection($c, $id_album_hot, $page, $limit);
}
}
if ($callBack) {
$this->layout = false;
$this->render("_ajaxList", compact('albums', 'pager', 'callBackLink', 'options'));
} else {
$this->render('list', array('albums' => $albums, 's' => $s, 'c' => $c, 'cTitle' => $cTitle, 'sTitle' => $sTitle, 'pager' => $pager, 'callBackLink' => $callBackLink, 'options' => $options));
}
}
示例11: fetchAllAndPage
public function fetchAllAndPage($conditions = "", $pageSize = null)
{
$pages = new CPagination($this->countByCondition($conditions));
$pageSize = is_null($pageSize) ? Yii::app()->params["basePerPage"] : $pageSize;
$pages->setPageSize(intval($pageSize));
$offset = $pages->getOffset();
$limit = $pages->getLimit();
$criteria = new CDbCriteria(array("limit" => $limit, "offset" => $offset));
$pages->applyLimit($criteria);
$fields = "*";
$sql = "SELECT {$fields} FROM {{tasks}}";
if (!empty($conditions)) {
$sql .= " WHERE " . $conditions;
}
$sql .= " ORDER BY sort DESC LIMIT {$offset},{$limit}";
$records = $this->getDbConnection()->createCommand($sql)->queryAll();
return array("pages" => $pages, "datas" => $records);
}
示例12: fetchAllByPage
public function fetchAllByPage($condition = "", $pageSize = 0)
{
$count = empty($condition) ? $this->count() : $this->countBySearchCondition($condition);
$pagination = new CPagination($count);
$pageSize = empty($pageSize) ? Yii::app()->params["basePerPage"] : $pageSize;
$pagination->setPageSize($pageSize);
$offset = $pagination->getOffset();
$limit = $pagination->getLimit();
$criteria = new CDbCriteria(array("limit" => $limit, "offset" => $offset));
$pagination->applyLimit($criteria);
$fields = "rd.realname,rb.checkid,rb.resumeid,rb.company,rb.position,rb.entrytime,rb.quittime";
$sql = "SELECT {$fields} FROM {{resume_bgchecks}} rb LEFT JOIN {{resume_detail}} rd ON rb.resumeid=rd.resumeid ";
if (!empty($condition)) {
$sql .= " WHERE " . $condition;
}
$sql .= " LIMIT {$offset},{$limit}";
$records = $this->getDbConnection()->createCommand($sql)->queryAll();
return array("pagination" => $pagination, "data" => $records);
}
示例13: actionIndex
public function actionIndex()
{
$keyword = Yii::app()->request->getParam('keyword', '');
$page = Yii::app()->request->getParam('page', 1);
// Find all records witch have first name starring on a, b and c, case insensitive search
$keyRegexPattern = self::formatKeywordsPatternSearch($keyword);
if (empty($keyRegexPattern)) {
$data = null;
} else {
$regexObj = new MongoRegex($keyRegexPattern);
$c = array('conditions' => array('status' => array('==' => 1), 'title' => array('==' => $regexObj)));
$total = WebArticlesModel::model()->count($c);
$pager = new CPagination($total);
$itemOnPaging = 5;
$pager->pageSize = 10;
$curr_page = $pager->getCurrentPage();
$limit = $pager->getLimit();
$offset = $pager->getOffset();
$c = array('conditions' => array('status' => array('==' => 1), 'title' => array('==' => $regexObj)), 'limit' => $limit, 'offset' => $offset);
$data = WebArticlesModel::model()->findAll($c);
}
$this->render('index', compact('data', 'pager', 'itemOnPaging', 'keyword', 'limit'));
}
示例14: actionView
/**
* function actionView
* call to render detail VideoPlaylist page
*/
public function actionView()
{
$id = (int) Yii::app()->request->getParam('id');
$video_id = Yii::app()->request->getParam('video_id', null);
$videoPlaylist = WapVideoPlaylistModel::model()->published()->with('video_playlist_artist')->findByPk($id);
$playPrice = $videoPlaylist->price;
if (!$videoPlaylist) {
$this->forward("/site/error", true);
}
$list_video_playlist = WapVideoModel::model()->getVideosOfVideoPlaylist($id);
//check noi dung doc quyen
$userType = "GUEST";
$phone = Yii::app()->user->getState('phone');
if ($phone) {
$userType = "MEMBER";
}
$userSub = Yii::app()->user->getState('userSub');
$packageCode = Yii::app()->user->getState('packageCode');
if ($userSub) {
$userType = "SUB_" . $packageCode;
}
$content_limit = ContentLimitModel::model()->getIdByType('video', 'WAP', $userType);
$list_video = array();
for ($i = 0; $i < count($list_video_playlist); $i++) {
if (!in_array($list_video_playlist[$i]->id, $content_limit)) {
$list_video[] = $list_video_playlist[$i];
}
}
$phone = Yii::app()->user->getState('msisdn');
$like = null;
if ($phone) {
$like = FavouriteVideoPlaylistModel::model()->findByAttributes(array('video_playlist_id' => $id, 'msisdn' => $phone));
}
$video = WapVideoModel::model()->with("video_extra")->findByPk($video_id);
$video = isset($video) ? $video : $list_video[0];
$artist_id = $videoPlaylist->video_playlist_artist[0]->artist_id;
$count = VideoPlaylistArtistModel::model()->countVideoPlaylistByArtist($artist_id);
$pager = new CPagination($count);
$pager->setPageSize(Yii::app()->params['numberPerPage']);
$videoPlaylistSameArtist = WapVideoPlaylistModel::model()->getVideoPlaylistsSameArtists($artist_id, $pager->getOffset(), $pager->getLimit());
$callBackLink = Yii::app()->createUrl("videoPlaylist/loadAjax", array('s' => 'artist', 'artist_id' => $artist_id));
$this->render('view', compact('video', 'list_video', 'videoPlaylist', 'pager', 'videoPlaylistSameArtist', 'callBackLink', 'like', 'artist_id'));
}
示例15: Pages
/**
*
* Enter description here ...
* @param unknown_type $params
*/
public static function Pages($params = array())
{
//设置默认参数
$_defaults_params = array('allow_cache' => true, 'page' => isset($_GET['page']) ? intval($_GET['page']) : 1, 'pagesize' => 15);
$params = array_merge($_defaults_params, $params);
//有开启缓存功能,则从缓存中取数据, 如果有数据,则直接返回结果
if ($params['allow_cache'] && isset(Yii::app()->cache)) {
$_cache_key = md5('content.archive.pages.' . serialize($params));
$_r = json_decode(Yii::app()->cache->get($_cache_key), true);
if ($_r && is_array($_r)) {
return $_r;
}
}
$cmd = Yii::app()->db->createCommand();
$cmd->select('COUNT(DISTINCT a.content_archives_id) AS COUNT')->from('{{content_archives}} a')->join('{{content_archives_classes_relating}} acr', 'acr.content_archives_id=a.content_archives_id')->join('{{content_archives_classes}} ac', 'ac.class_id=acr.class_id')->join('{{content_model}} m', 'm.content_model_id=ac.content_model_id');
//添加条件
if (isset($params['content_archives_status']) && !empty($params['content_archives_status'])) {
$__addons = array('AND', 'a.content_archives_status=:content_archives_status');
$__params = array(':content_archives_status' => $params['content_archives_status']);
} else {
$__addons = array('AND', 'a.content_archives_status>:content_archives_status');
$__params = array(':content_archives_status' => 0);
}
//
if (isset($params['content_archives_id']) && !empty($params['content_archives_id'])) {
$__addons[] = array('AND', 'a.content_archives_id=:content_archives_id');
$__params[':content_archives_id'] = $params['content_archives_id'];
}
//
if (isset($params['content_model_id']) && !empty($params['content_model_id'])) {
$__addons[] = array('AND', 'ac.content_model_id=:content_model_id');
$__params[':content_model_id'] = $params['content_model_id'];
}
//
if (isset($params['class_id']) && !empty($params['class_id'])) {
$_classes = ContentArchivesClass::get_classes_children($params['class_id']);
$_s = '';
foreach ($_classes as $_k => $_v) {
$_s .= ",:class_id{$_k}";
$__params[":class_id{$_k}"] = $_v;
}
$_s = trim($_s, ',');
$__addons[] = array('AND', "acr.class_id IN({$_s})");
unset($_classes, $_s);
}
//
if (isset($params['content_archives_subject']) && !empty($params['content_archives_subject'])) {
$__addons[] = array('OR', array('OR LIKE', 'a.content_archives_subject', "%{$params['content_archives_subject']}%"));
//$__addons[] = array('LIKE', 'a.content_archives_name', '%:content_archives_name%');
//$__params = array_merge($__params, array(':content_archives_name'=>$params['content_archives_name']));
}
//
if (isset($params['search_key']) && $params['search_key']) {
if (is_numeric($params['search_key'])) {
$__addons[] = array('AND', 'a.content_archives_id=:content_archives_id');
$__params[':content_archives_id'] = $params['search_key'];
} else {
$__addons[] = array('OR', array('OR LIKE', 'a.content_archives_subject', "%{$params['search_key']}%"));
}
//$__params = array_merge($__params, array(':search_key'=>$params['search_key']));
}
$cmd->where($__addons, $__params);
//统计数量
$count = $cmd->queryScalar();
//分页处理
$pages = new CPagination($count);
//设置分页大小
$pages->pageSize = $params['pagesize'];
//清空前面执行过的SQL
$cmd->setText('');
if (isset($params['orderby']) && $params['orderby']) {
$cmd->order($params['orderby']);
} else {
$cmd->order(array('a.content_archives_rank ASC', 'a.content_archives_dateline DESC'));
}
$cmd->select('a.content_archives_id, ac.content_model_id, m.content_model_name, ac.class_id, ac.class_name, a.content_archives_subject, a.content_archives_color, a.content_archives_short_subject, a.content_archives_flag, a.content_archives_jump_url, a.content_archives_source, a.content_archives_author, a.content_archives_thumb, a.content_archives_keywords, a.content_archives_summary, a.content_archives_status, a.content_archives_rank, a.content_archives_pubtime, a.content_archives_is_build, a.content_archives_lasttime, a.content_archives_dateline')->group('a.content_archives_id')->limit($pages->getLimit())->offset($pages->getOffset());
$_r['pages'] = $pages;
$_r['rows'] = $cmd->queryAll();
//有开启缓存,则把结果添加到缓存中
if ($params['allow_cache'] && isset(Yii::app()->cache)) {
$_cache_cache_time = Setting::getSettingCache('CONTENT_ARCHIVES_PAGES_CACHE_TIME');
Yii::app()->cache->set($_cache_key, json_encode($_r), $_cache_cache_time);
unset($_cache_cache_time, $_cache_key);
}
return $_r;
}