本文整理汇总了PHP中Pagination::getResults方法的典型用法代码示例。如果您正苦于以下问题:PHP Pagination::getResults方法的具体用法?PHP Pagination::getResults怎么用?PHP Pagination::getResults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pagination
的用法示例。
在下文中一共展示了Pagination::getResults方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: results
public function results()
{
$id = $this->getParam(0, 0);
$type_label = $this->getParam(1, 0);
$page = !empty($this->getParam(2, 0)) ? (int) $this->getParam(2, 0) : 1;
//$search_query = $this->request->get('q', '');
$labels = Info::$type_labels;
$type_label = ucfirst(str_replace('-', ' ', $type_label));
$type = array_search($type_label, $labels);
//$infos = Info::getElements($id, $type);
/*
$vars = array (
'id' => $id,
'type_label' => $type_label,
'infos' => $infos,
'labels' => $labels
);
*/
$sql = 'SELECT id, quarter_id, name, type, description, url, rating, theme FROM info WHERE quarter_id = :quarter_id AND type = :type ORDER BY id ASC';
$bindings = array('quarter_id' => $id, 'type' => $type);
$pagination = new Pagination($sql, $bindings, 16, $page - 1);
$results = $pagination->getResults();
foreach ($results as $result) {
$infos[] = new Info($result);
}
//foreach ($infos as $key => $info) {
// $info->description=substr($info->description,0, 50);
//}
$vars = array('id' => $id, 'type_label' => $type_label, 'infos' => $infos, 'labels' => $labels, 'page' => $page, 'count_pages' => $pagination->getPagesCount(), 'count_total' => $pagination->getTotalCount());
$this->render('elements', $vars);
}
示例2: results
public function results()
{
$params = $this->getParams();
$search_query = $this->request->get('q', '');
$page = !empty($params[0]) ? (int) $params[0] : 1;
$vars = array('title' => 'Search', 'description' => 'Description', 'page' => $page, 'count_pages' => 0, 'posts' => array(), 'count_total' => 0, 'search_query' => $search_query);
if (!empty($search_query)) {
$pagination = new Pagination('SELECT * FROM post WHERE title LIKE :search OR content LIKE :search ORDER BY date DESC', array(':search' => '%' . $search_query . '%'), 5, $page - 1);
$vars = array_merge($vars, array('page' => $page, 'count_pages' => $pagination->getPagesCount(), 'posts' => $pagination->getResults(), 'count_total' => $pagination->getTotalCount()));
}
$this->render('search', $vars);
}
示例3: results
public function results()
{
$page = !empty($this->getParam(0, 0)) ? (int) $this->getParam(0, 0) : 1;
//$pictures = Picture::getList('SELECT id, quarter_id, src, info_id, user_id FROM photo WHERE user_id IS NOT NULL ORDER BY id DESC');
$sql = 'SELECT id, quarter_id, src, info_id, user_id FROM photo WHERE user_id IS NOT NULL ORDER BY id DESC';
$bindings = array();
$pagination = new Pagination($sql, $bindings, 20, $page - 1);
$results = $pagination->getResults();
foreach ($results as $result) {
$pictures[] = new Picture($result);
}
$vars = array('pictures' => $pictures, 'page' => $page, 'count_pages' => $pagination->getPagesCount(), 'count_total' => $pagination->getTotalCount());
$this->render('wall', $vars);
}
示例4: archives
public function archives()
{
$params = $this->getParams();
$date = !empty($params[0]) ? $params[0] : date('Y-m');
$page = !empty($params[1]) ? (int) $params[1] : 1;
$time = strtotime($date);
$date_label = ucfirst(Lang::_(strtolower(date('F', $time)))) . ' ' . date('Y', $time);
$pagination = new Pagination('SELECT * FROM post WHERE DATE_FORMAT(date, "%Y-%m") = :date ORDER BY date DESC', array(':date' => $date), 4, $page - 1);
/*
// Same with date split without mysql function DATE_FORMAT()
$date_parts = explode('-', $date);
$year = $date_parts[0];
$month = $date_parts[1];
$pagination = new Pagination('SELECT * FROM post WHERE YEAR(date) = :year AND MONTH(date) = :month ORDER BY date DESC', array(':year' => $year, ':month' => $month), 4, $page - 1);
*/
$vars = array('title' => 'Title', 'description' => 'Description', 'date' => $date, 'date_label' => $date_label, 'page' => $page, 'count_pages' => $pagination->getPagesCount(), 'count_total' => $pagination->getTotalCount(), 'posts' => $pagination->getResults());
$this->render('archives', $vars);
}
示例5: results
public function results()
{
$params = $this->getParams();
$quick_search = $this->request->get('qs');
$advanced_search = $this->request->get('as');
$search_query = $this->request->get('q', '');
$quarter = $this->request->get('quarter', '');
$type = $this->request->get('type', '');
$theme = $this->request->get('theme', '');
$page = !empty($params[0]) ? (int) $params[0] : 1;
$infos = array();
$quarters = Quarter::getList('SELECT id, name FROM quarter ORDER BY name ASC');
$types = Info::$type_labels;
$themes_query = Db::select('SELECT DISTINCT(theme) FROM info WHERE theme IS NOT NULL AND theme != "" ORDER BY theme');
$themes = array();
foreach ($themes_query as $row) {
$_theme = $row['theme'];
if (strpos($_theme, '|') !== false) {
$theme_parts = explode('|', $_theme);
foreach ($theme_parts as $_theme) {
if (!in_array($_theme, $themes)) {
$themes[] = $_theme;
}
}
continue;
}
$themes[] = $_theme;
}
$vars = array('title' => 'Search', 'description' => 'Description', 'quarters' => $quarters, 'types' => $types, 'themes' => $themes, 'page' => $page, 'count_pages' => 0, 'infos' => $infos, 'count_total' => 0, 'search_query' => $search_query, 'quarter' => $quarter, 'type' => $type, 'theme' => $theme, 'qs' => $quick_search, 'as' => $advanced_search);
$sql = 'SELECT i.* FROM quarter q LEFT JOIN info i ON i.quarter_id = q.id WHERE 1 ';
if (!empty($search_query)) {
$sql .= 'AND (q.name LIKE :search OR q.description LIKE :search OR i.name LIKE :search OR i.description LIKE :search) ';
$bindings = array('search' => '%' . $search_query . '%');
}
if (!empty($advanced_search)) {
if (!empty($quarter)) {
$sql .= 'AND q.id = :quarter ';
$bindings['quarter'] = $quarter;
}
if (!empty($type)) {
$sql .= 'AND i.type = :type ';
$bindings['type'] = $type;
}
if (!empty($theme)) {
$sql .= 'AND i.theme LIKE :theme ';
$bindings['theme'] = '%' . $theme . '%';
}
}
if (!empty($bindings)) {
$pagination = new Pagination($sql, $bindings, 10, $page - 1);
$results = $pagination->getResults();
foreach ($results as $result) {
$infos[] = new Info($result);
}
foreach ($infos as $key => $info) {
$info->description = substr($info->description, 0, 200);
}
$vars = array_merge($vars, array('page' => $page, 'count_pages' => $pagination->getPagesCount(), 'infos' => $infos, 'count_total' => $pagination->getTotalCount()));
}
$this->render('search', $vars);
}
示例6: list_users
function list_users($page = 1, $keyword = '')
{
//Return users list, for admin use
$output = '';
$count = 10;
$users = $keyword != '' ? array_filter(load_all_array('nsh_users'), array(new filter($keyword), 'filter_keyword')) : load_all_array('nsh_users');
usort($users, 'sort_name_ascend');
$users_count = count($users);
$pagination = new Pagination($users, $page, $count, 20);
$pagination->setShowFirstAndLast(true);
$pagination->setMainSeperator('');
$users = $pagination->getResults();
$output .= '<a class="button right" href="/user/create/">Create user</a>';
$output .= '<span class="count">' . $users_count . ' user' . ($users_count > 1 ? 's' : '') . '.</span>';
$output .= '<div class="paging">' . $pagination->getLinks() . '</div>';
$output .= '<table class="admin">';
$output .= '<tr><th>ID</th><th>User ID</th><th>Username</th><th>DOB</th><th colspan="2">Operations</th></tr>';
for ($i = 0; $i < $count; ++$i) {
if (isset($users[$i])) {
$class = 'class="' . table_row_class($i) . '"';
$output .= '<tr ' . $class . '>';
$output .= '<td>' . (($page - 1) * $count + ($i + 1)) . '</td>';
$output .= '<td>' . $users[$i]['uid'] . '</td>';
$output .= '<td><a style="color: black" target="_blank" href="/?fullname=' . str_replace(' ', '+', $users[$i]['name']) . '&dob=' . $users[$i]['dob'] . '">' . $users[$i]['name'] . '</a></td>';
$output .= '<td>' . $users[$i]['dob'] . '</td>';
$output .= '<td><form method="POST" action="/user/edit/"><input type="hidden" name="uid" value="' . $users[$i]['uid'] . '" /><input type="hidden" name="old_name" value="' . $users[$i]['name'] . '" /><input type="hidden" name="old_dob" value="' . $users[$i]['dob'] . '" /><input name="user_edit" type="submit" value="Edit"/></form></td>';
$output .= '<td><form method="POST" action="/user/delete/"><input type="hidden" name="uid" value="' . $users[$i]['uid'] . '" /><input name="user_delete" type="submit" value="Delete"/></form></td>';
$output .= '</tr>';
}
}
$output .= '</table>';
$output .= '<div class="paging">' . $pagination->getLinks() . '</div>';
$output .= '<script>
function turnPage(page) {
$("#admin_user").load("/triggers/admin_user.php",{page:page,keyword:"' . $keyword . '"});
}
</script>';
return $output;
}