本文整理汇总了PHP中Pager::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Pager::get方法的具体用法?PHP Pager::get怎么用?PHP Pager::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pager
的用法示例。
在下文中一共展示了Pager::get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: defaultAction
public function defaultAction()
{
$pageSize = 20;
// 获取参数
$page = Pager::get();
$title = Request::getGET('title');
$status = (int) Request::getGET('status');
// 构建where
$where = array(array('user_id', '=', $this->loginUserInfo['id']), array('is_diy', '=', 1));
if (!empty($status) && $status != -1) {
$where[] = array('hidden', '=', $status - 1);
}
if (!empty($title)) {
$where[] = array('title', 'LIKE', "%{$title}%");
}
// 获取数据
$offset = ($page - 1) * $pageSize;
$contestList = OjContestInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
$allCount = 0;
if (!empty($contestList)) {
$allCount = OjContestInterface::getCount($where);
}
$userIds = array_unique(array_column($contestList, 'user_id'));
$userHash = UserCommonInterface::getById(array('id' => $userIds));
// 缓存部分的html
$html = array();
$html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
// 输出
$this->renderFramework(array('contestList' => $contestList, 'userHash' => $userHash, 'html' => $html), 'setup/contest/list.php');
}
示例2: defaultAction
public function defaultAction()
{
$pageSize = 20;
// 获取参数
$page = Pager::get();
$status = (int) Request::getGET('status', -1);
$contestId = (int) Request::getGET('contest-id', 0);
$where = array();
$where[] = array('is_diy', '=', 0);
if (!empty($contestId)) {
$where[] = array('contest_id', '=', $contestId);
}
if ($status != -1) {
$where[] = array('status', '=', $status);
}
// 获取数据
$offset = ($page - 1) * $pageSize;
$applyList = OjContestApplyInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
$allCount = 0;
$userHash = array();
$contestHash = array();
if (!empty($applyList)) {
$allCount = OjContestApplyInterface::getCount($where);
$userIds = array_column($applyList, 'user_id');
$userHash = UserCommonInterface::getById(array('id' => $userIds));
$contestIds = array_unique(array_column($applyList, 'contest_id'));
$contestHash = OjContestInterface::getById(array('id' => $contestIds));
}
// 缓存部分的html
$html = array();
$html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
$this->renderFramework(array('html' => $html, 'applyList' => $applyList, 'contestHash' => $contestHash, 'userHash' => $userHash), 'contest/apply_list.php');
}
示例3: defaultAction
public function defaultAction()
{
$pageSize = 50;
$page = Pager::get();
$category = (int) Request::getGET('category', -1);
$title = trim(Request::getGET('title', ''));
$username = trim(Request::getGET('username', ''));
$where = array();
if ($category != -1) {
$where[] = array('category', '=', $category);
}
if (!empty($username)) {
$userInfo = UserCommonInterface::getByLoginName(array('login_name' => $username));
$where[] = array('user_id', '=', Arr::get('id', $userInfo, 0));
}
if (!empty($title)) {
$where[] = array('title', 'LIKE', "%{$title}%");
}
if ($category != -1) {
$order = array('hidden' => 'ASC', 'title' => 'ASC', 'id' => 'DESC');
} else {
$order = array('id' => 'DESC');
}
$offset = ($page - 1) * $pageSize;
$docList = DocInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset));
$allCount = empty($docList) ? 0 : DocInterface::getCount($where);
$userIds = array_unique(array_column($docList, 'user_id'));
$userHash = UserCommonInterface::getById(array('id' => $userIds));
// 缓存部分的html
$html = array();
$html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 7), 'widget/pager.php');
$this->renderFramework(array('html' => $html, 'docList' => $docList, 'userHash' => $userHash), 'doc/list.php');
}
示例4: defaultAction
public function defaultAction()
{
$pageSize = 50;
// 获取参数
$page = Pager::get();
$contestId = (int) Request::getGET('contest-id');
$status = (int) Request::getGET('status', -1);
$contestInfo = OjContestInterface::getById(array('id' => $contestId));
if (empty($contestInfo) || $contestInfo['hidden'] || $contestInfo['type'] != ContestVars::TYPE_APPLY) {
$this->renderError('竞赛不存在,或者竞赛不需要报名!');
}
// 构建where
$where = array();
$where[] = array('contest_id', '=', $contestId);
if ($status != -1) {
$where[] = array('status', '=', $status);
}
// 获取数据
$offset = ($page - 1) * $pageSize;
$applyList = OjContestApplyInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
$allCount = OjContestApplyInterface::getCount($where);
// userHash
$userIds = array_unique(array_column($applyList, 'user_id'));
$userHash = UserCommonInterface::getById(array('id' => $userIds));
// 缓存部分的html
$html = array();
$html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
$this->renderFramework(array('html' => $html, 'applyList' => $applyList, 'contestInfo' => $contestInfo, 'userHash' => $userHash), 'contest/apply_list.php');
}
示例5: defaultAction
public function defaultAction()
{
$pageSize = 100;
// 获取参数
$page = Pager::get();
$remote = (int) Request::getGET('remote', 0);
$keyword = Request::getGET('keyword');
$searchType = (int) Request::getGET('search-type', 1);
// 构建where
$where = array();
$where[] = array('remote', '=', $remote);
$where[] = array('hidden', '=', 0);
if (!empty($keyword)) {
if ($searchType == 1) {
$where[] = array('OR' => array(array('problem_code', '=', $keyword), array('title', 'LIKE', "%{$keyword}%")));
} else {
if ($searchType == 2) {
$where[] = array('OR' => array(array('problem_code', '=', $keyword), array('source', 'LIKE', "%{$keyword}%")));
}
}
}
// 获取数据
$order = array('problem_code' => 'ASC');
$offset = ($page - 1) * $pageSize;
$problemList = OjProblemInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset));
$allCount = OjProblemInterface::getCount($where);
// 获取用户解决的题目
$userSolution = array();
if ($this->loginUserInfo) {
$globalIds = array_column($problemList, 'id');
$where = array(array('user_id', '=', $this->loginUserInfo['id']), array('contest_id', '=', 0), array('problem_global_id', 'IN', $globalIds));
$solutionList = OjSolutionInterface::getList(array('where' => $where));
foreach ($solutionList as $solutionId => $solutionInfo) {
$globalId = $solutionInfo['problem_global_id'];
if (!array_key_exists($globalId, $userSolution) || $solutionInfo['result'] == StatusVars::ACCEPTED) {
$userSolution[$globalId] = $solutionInfo;
}
}
}
$userHash = array();
if ($allCount > 0) {
$userIds = array_unique(array_column($problemList, 'user_id'));
$userHash = UserCommonInterface::getById(array('id' => $userIds));
}
// 缓存部分的html
$html = array();
$html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 10), 'widget/pager.php');
$tpl = $remote ? 'problem/list_remote.php' : 'problem/list.php';
// 输出
$this->renderFramework(array('html' => $html, 'problemList' => $problemList, 'userSolution' => $userSolution, 'userHash' => $userHash), $tpl);
}
示例6: defaultAction
public function defaultAction()
{
$pageSize = 50;
// 获取参数
$page = Pager::get();
$title = Request::getGET('title');
$status = (int) Request::getGET('status');
$username = Request::getGET('username');
// userInfo
$userInfo = array();
if (!empty($username)) {
$userInfo = UserCommonInterface::getByLoginName(array('login_name' => $username));
}
// 构建where
if (!empty($username) && empty($userInfo)) {
$where = false;
} else {
$where = array();
if (!empty($userInfo)) {
$where[] = array('user_id', '=', $userInfo['id']);
}
if (!empty($status) && $status != -1) {
$where[] = array('hidden', '=', $status - 1);
}
if (!empty($title)) {
$where[] = array('title', 'LIKE', "%{$title}%");
}
}
$order = array('listing_status' => 'DESC', 'refresh_at' => 'DESC', 'id' => 'DESC');
$offset = ($page - 1) * $pageSize;
$setList = OjProblemSetInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset));
$allCount = 0;
if (!empty($setList)) {
$allCount = OjProblemSetInterface::getCount($where);
}
foreach ($setList as &$setInfo) {
$globalIds = (array) json_decode($setInfo['problem_set'], true);
$setInfo['count'] = count($globalIds);
}
// 获取用户
$userIds = array_unique(array_column($setList, 'user_id'));
$userHash = UserCommonInterface::getById(array('id' => $userIds));
// 缓存部分的html
$html = array();
$html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
// 输出
$this->renderFramework(array('html' => $html, 'setList' => $setList, 'userHash' => $userHash), 'set/list.php');
}
示例7: get
/**
* テーブルを検索してデータ一覧を取得する
*
* @param (array|string) $conditions テーブルの検索条件
* @param integer $currentPage 取得するページ
* @return array テーブルから取得したデータの配列
*/
public function get($conditions, $currentPage)
{
$_ = $this;
// SELECT 条件の設定
$_->TABLE->reset();
$_->TABLE->select('*');
$_->setLimit($currentPage, $this->maxItemsInPage);
// SELECTの結果取得
$results = $_->TABLE->find($conditions)->fetchAll();
// ページャの生成
$pagerParams['currentPage'] = $currentPage;
$pagerParams['allItemsNum'] = $_->count($conditions);
$pagerParams['maxItemsInPage'] = $_->maxItemsInPage;
$_->pager = Pager::get($pagerParams);
return $results;
}
示例8: defaultAction
public function defaultAction()
{
$pageSize = 20;
// 获取参数
$page = Pager::get();
$status = (int) Request::getGET('status', -1);
$contestId = (int) Request::getGET('contest-id', 0);
// 获取属于用户的竞赛
$where = array(array('user_id', '=', $this->loginUserInfo['id']), array('is_diy', '=', 1));
$contestHash = OjContestInterface::getList(array('where' => $where));
$contestHash = Arr::listToHash('id', $contestHash);
$contestIds = array_keys($contestHash);
$userHash = array();
$applyList = array();
$allCount = 0;
if (!empty($contestIds)) {
if ($contestId > 0 && !in_array($contestId, $contestIds)) {
$where = false;
} else {
if ($contestId > 0 && in_array($contestId, $contestIds)) {
$where = array(array('contest_id', '=', $contestId));
} else {
$where = array(array('contest_id', 'IN', $contestIds));
}
}
if (false !== $where) {
if ($status != -1) {
$where[] = array('status', '=', $status);
}
$offset = ($page - 1) * $pageSize;
$applyList = OjContestApplyInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
if (!empty($applyList)) {
$allCount = OjContestApplyInterface::getCount($where);
$userIds = array_column($applyList, 'user_id');
$userHash = UserCommonInterface::getById(array('id' => $userIds));
}
}
}
// 缓存部分的html
$html = array();
$html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
$this->renderFramework(array('html' => $html, 'applyList' => $applyList, 'contestHash' => $contestHash, 'userHash' => $userHash), 'setup/contest/apply_list.php');
}
示例9: defaultAction
public function defaultAction()
{
$pageSize = 20;
// 获取参数
$page = Pager::get();
$keyword = Request::getGET('keyword');
// 构建where
$where = array();
if (!empty($keyword)) {
$where[] = array('OR' => array(array('code', 'LIKE', "%{$keyword}%"), array('description', 'LIKE', "%{$keyword}%")));
}
// 查询
$offset = ($page - 1) * $pageSize;
$permissionList = RootPermissionInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
$allCount = RootPermissionInterface::getCount($where);
// 缓存部分的html
$html = array();
$html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
$this->renderFramework(array('html' => $html, 'permissionList' => $permissionList), 'permission/list.php');
}
示例10: defaultAction
public function defaultAction()
{
$pageSize = 20;
$page = Pager::get();
$level = (int) Request::getGET('level');
$key = Request::getGET('key');
$where = array();
if ($key == 'phpErrors') {
$where[] = array('tag', 'IN', LoggerKeys::$phpErrors);
} else {
if (!empty($key)) {
$where[] = array('tag', '=', $key);
}
}
if (!empty($level)) {
$where[] = array('level', '=', $level);
}
$logList = LoggerInterface::getList(array('field' => '*', 'where' => $where, 'limit' => $pageSize, 'offset' => ($page - 1) * $pageSize));
$allCount = LoggerInterface::getCount($where);
// 缓存部分的html
$html = array();
$html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 4), 'widget/pager_long.php');
$this->renderFramework(array('html' => $html, 'logList' => $logList), 'list.php');
}