本文整理汇总了PHP中Pagination::offset方法的典型用法代码示例。如果您正苦于以下问题:PHP Pagination::offset方法的具体用法?PHP Pagination::offset怎么用?PHP Pagination::offset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pagination
的用法示例。
在下文中一共展示了Pagination::offset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Pagination
static function find_paginated($page = 1, $fields = "*", $where_clause = "", $order = "ASC")
{
$total_count = static::count_all();
$pagination = new Pagination($page, $total_count, ITEMS_PER_PAGE);
$query = "SELECT {$fields} FROM `" . static::$table_name . "` ";
$query .= $where_clause;
$query .= "ORDER BY `" . ID . "` {$order} ";
$query .= "LIMIT " . ITEMS_PER_PAGE . " ";
$query .= "OFFSET " . $pagination->offset();
return static::find_by_query($query);
}
示例2: getSubsetOfProperties
/**
* Return a subset of property objects to use
* in pagination of records
* @param object $paginationObj A pagination object
* @return array An array of property objects
*/
public static function getSubsetOfProperties(Pagination $paginationObj)
{
$db = Database::getInstance();
$mysqli = $db->getConnection();
$sql = "SELECT * FROM property p ORDER BY name ASC ";
$sql .= "LIMIT " . $mysqli->real_escape_string($paginationObj->per_page) . " ";
$sql .= "OFFSET " . $paginationObj->offset();
return static::findBySql($sql);
}
示例3: Pagination
redirect_to($_SERVER['PHP_SELF']);
die;
}
}
$page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
$per_page = JOBS_PER_SEARCH;
$total_count = Job::count_all();
$smarty->assign('total_count', $total_count);
$smarty->assign('page', $page);
$pagination = new Pagination($page, $per_page, $total_count);
$smarty->assign('previous_page', $pagination->previous_page());
$smarty->assign('has_previous_page', $pagination->has_previous_page());
$smarty->assign('total_pages', $pagination->total_pages());
$smarty->assign('has_next_page', $pagination->has_next_page());
$smarty->assign('next_page', $pagination->next_page());
$offset = $pagination->offset();
$sql = " SELECT * FROM " . TBL_JOB;
$sql .= " LIMIT {$per_page} ";
$sql .= " OFFSET {$offset} ";
$lists = Job::find_by_sql($sql);
$manage_lists = array();
if ($lists && is_array($lists)) {
$i = 1;
foreach ($lists as $list) {
unset($employer);
if (!empty($list->fk_employer_id) && $list->fk_employer_id != 0) {
$employer = Employer::find_by_id($list->fk_employer_id);
}
$manage_lists[$i]['id'] = $list->id;
$manage_lists[$i]['job_title'] = $list->job_title;
$manage_lists[$i]['spotlight'] = $list->spotlight == "Y" ? "Spotlight Job" : "Standard Job";
示例4: ceil
<?php
include "includes/header.php";
$page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
$items_per_page = 2;
$items_total_count = Photo::count_all();
$pages = ceil($items_total_count / $items_per_page);
$paginate = new Pagination($page, $items_per_page, $items_total_count);
$query = "SELECT * FROM photos ";
$query .= " LIMIT {$items_per_page} ";
$query .= "OFFSET {$paginate->offset()}";
$photos = Photo::find_this_query($query);
?>
<div class="row">
<!-- Blog Entries Column -->
<div class="col-md-12">
<div class="thumbnails row">
<?php
foreach ($photos as $photo) {
?>
<div class="col-xs-6 col-md-3">
<a href="<?php
echo 'photo.php?id=' . $photo->id;
?>
" class="thumbnail">
<img class="gallery_photo img-responsive"
src="<?php
示例5: paginate
/**
* Add pagination
*
* @param int $limit the number of items per page
* @param array $options and optional array with options for the pagination class
* @return object a sliced set of data
*/
public function paginate($limit, $options = array())
{
if (is_a($limit, 'Pagination')) {
$this->pagination = $limit;
return $this;
}
$pagination = new Pagination($this->count(), $limit, $options);
$pages = $this->slice($pagination->offset(), $pagination->limit());
$pages->pagination = $pagination;
return $pages;
}
示例6: output_message
<?php
require_once '../includes/initialize.php';
?>
<?php
include_layout_template("header.php");
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
$record_no = 3;
$total_records = Photograph::count();
// $photo_object = new Photograph();
// $photos = $photo_object->find_all();
$pagination = new Pagination($page, $record_no, $total_records);
$sql_query = "SELECT * FROM photograph ";
$sql_query .= "LIMIT {$record_no} ";
$sql_query .= "OFFSET {$pagination->offset()} ";
$photos = Photograph::find_by_sql($sql_query);
?>
<h2>Photos</h2>
<?php
echo output_message($session->set_get_message());
?>
<?php
foreach ($photos as $photo) {
?>
<div style="float:left;margin-left: 20px; display:inline;">
<a href="photo.php?id=<?php
echo $photo->id;
?>
">
<img src="<?php
示例7: Pagination
print_r($ques_status);
echo "<br/>";*/
$ques_options = $_SESSION['temp_options'];
$pg = new Pagination($page, $per_page, $total_count);
$tt = new Test();
if (isset($_SESSION['first_time'])) {
$tt->Review_Test();
} else {
unset($_SESSION['first_time']);
}
$ques_set = $tt->GetAllQues();
?>
<table width="933" border="0" cellspacing="0" cellpadding="0" class="revtab">
<?php
$check = $per_page * $page > $total_count ? $total_count : $per_page * $page;
for ($i = $pg->offset(); $i < $check; $i++) {
$id = $ques_ids[$i];
?>
<tr>
<td width="53"><?php
echo $i + 1;
?>
</td>
<td width="687" ><?php
echo $ques_set[$i];
?>
</td>
<td><input type="button" class="button orange" onClick="call_test(<?php
echo $id;
?>
,'<?php
示例8: buildQuery
$updated_session = [SessionOperator::SORT => $sort];
} else {
HelperOperator::redirectTo("../views/search_view.php");
return;
}
}
}
$cats = getCatIdAndType($searchCategory);
// Set up pagination object
$total = QueryOperator::countFoundAuctions(buildQuery($searchString, $cats, null));
$page = isset($_GET["page"]) ? $_GET["page"] : 1;
$page = $page <= $total ? $page : 1;
$per_page = 15;
$pagination = new Pagination($page, $per_page, $total);
// Get paginated search results
$catsAndAuctions = QueryOperator::searchAuctions(buildQuery($searchString, $cats, $sort, $per_page, $pagination->offset()));
// Update search sessions
$updated_session = array_merge([SessionOperator::SEARCH_RESULT => $catsAndAuctions], $updated_session);
$updated_session = array_merge([SessionOperator::SEARCH_PAGINATION => $pagination], $updated_session);
SessionOperator::setSearch($updated_session);
// Return back to search page
HelperOperator::redirectTo("../views/search_view.php");
function buildQuery($searchString, $searchCategory, $sortOption, $limit = null, $offset = null)
{
$query = null;
// Prepare count query
if (is_null($limit) && is_null($offset)) {
$query = "SELECT COUNT(*) ";
} else {
$query = "SELECT auctions.auctionId, quantity, startPrice, reservePrice, startTime,\n endTime, itemName, itemBrand, itemDescription, items.image, auctions.views,\n item_categories.categoryName as subCategoryName, superCategoryName,\n item_categories.superCategoryId, item_categories.categoryId,\n conditionName, countryName, COUNT(DISTINCT (bids.bidId)) AS numBids,\n COUNT(DISTINCT (auction_watches.watchId)) AS numWatches,\n MAX(bids.bidPrice) AS highestBid,\n case\n when MAX(bids.bidPrice)is not null THEN MAX(bids.bidPrice)\n else startPrice\n end AS currentPrice ";
}
示例9:
?>
</a> </li>
<?php
}
?>
</ul>
</div>
<div class="rightcol">
<div id="change"><!-- this is to load ajax page when required-->
<p class="name" style="margin-top:-2px;"><span class="txtshd"><?php
echo $user->fullname;
?>
</span ></p>
<?php
$test_record = $test->last_test_record($_SESSION['owner_id'], $_SESSION['uname'], $per_page, $pagination->offset());
if ($test_record) {
echo '<table class="records">';
echo "<tr style='font-size:18px;' align='center'><td>Previous Records:</td><td></td><td></td></tr>";
echo "<tr>";
echo "<th>";
echo "Course";
echo "</th>";
echo "<th>";
echo "Date Of Test";
echo "</th>";
echo "<th>";
echo "Score Obtained";
echo "</th>";
echo "<th>";
echo "Questions Correct";
示例10: Menu
<table class="table table-striped table-bordered table-hover table-responsive">
<thead>
<tr>
<th style="color:green">Menu Name</th>
<th style="color:green">Description</th>
<th style="color:green">Price</th>
<th style="color:red;" colspan="2">Actions</th>
</tr>
</thead>
</tbody>
<?php
$p = new Menu();
$list_of_menu = array();
$list_of_menu = $p->loadMenu($pagination->per_page, $pagination->offset());
foreach ($list_of_menu as $menu) {
?>
<tr>
<td><?php
echo $menu->menu_name;
?>
</td>
<td><?php
echo $menu->menu_description;
?>
</td>
<td><?php
echo $menu->menu_price;
?>
示例11: Pagination
<?php
require_once '../includes/initialize.php';
//Paging
$page = !empty($_GET['page']) ? (int)$_GET['page'] : 1;
$per_page = 3;
$total_count = Photograph::count_all();
$pagination = new Pagination($page, $per_page, $total_count);
$sql = "select * from photographs limit {$per_page} offset {$pagination->offset()}";
$photos = Photograph::find_by_sql($sql);
include_layout_template("header.php");
?>
<p></p><a href="./admin/list_photos.php">Show Lists</a></p>
<b/>
<?
foreach ($photos as $photo): ?>
<div style="float: left; margin-left:20px;">
<a href="photo.php?id=<?= $photo->id ?>">
<img src="../<? echo $photo->image_path(); ?>" width="150"/>
</a>
<p><?= $photo->caption ?></p>
</div>
<?php endforeach; ?>
示例12: paginer
public static function paginer(Condition $listeConditions = NULL, $nbElementsParPage, $pageCourante = 1)
{
// Création d'un objet Pagination qui contiendra toutes les caractéristiques
$pagination = new Pagination();
// On définit ensuite les caractéristiques de la pagination
$pagination->setNbElementsParPage($nbElementsParPage);
$pagination->setNbElementsTotal(self::compter());
$pagination->setPageCourante($pageCourante);
$pagination->calculer();
$pagination->setListeElements(self::obtenirTout($listeConditions, $pagination->offset(), $nbElementsParPage));
return $pagination;
}
示例13: getSearchResultLoop
function getSearchResultLoop($s, $max_pp = null)
{
if (!isset($this->p)) {
$s = $this->conn->real_escape_string(urldecode($s));
$loop_first_search_query = "SELECT * FROM c_posts WHERE (post_content LIKE '%{$s}%' OR post_excerpt LIKE '%{$s}%' OR post_title LIKE '%{$s}%' OR post_description LIKE '%{$s}%' OR link_title LIKE '%{$s}%' OR tags LIKE '%{$s}%') AND post_status <> 'Initialized'";
$this->res = $this->conn->query($loop_first_search_query);
dbQueryCheck($this->res, $this->conn);
$this->search_res_count = $this->res->num_rows;
// set search result count, should be accessed only after function call
$this->p = 'set';
}
if (!isset($loop_search_query)) {
$s = $this->conn->real_escape_string(urldecode($s));
$pagination = new Pagination($max_pp, $this->search_res_count);
$loop_search_query = "SELECT * FROM c_posts WHERE (post_content LIKE '%{$s}%' OR post_excerpt LIKE '%{$s}%' OR post_title LIKE '%{$s}%' OR post_description LIKE '%{$s}%' OR link_title LIKE '%{$s}%' OR tags LIKE '%{$s}%') AND post_status <> 'Initialized' ";
$loop_search_query .= "LIMIT {$pagination->per_page} ";
$loop_search_query .= "OFFSET {$pagination->offset()}";
}
if (!isset($this->j)) {
$this->res = $this->conn->query($loop_search_query);
dbQueryCheck($this->res, $this->conn);
$this->j = 'set';
}
$this->total_pages = $pagination->totalPages();
$this->hasPreviousPage = $pagination->hasPreviousPage();
$this->hasNextPage = $pagination->hasNextPage();
$this->previousPage = $pagination->previousPage();
$this->nextPage = $pagination->nextPage();
return $this->res->fetch_assoc();
}
示例14: Pagination
$rel_id = get_related_sub_cat($mainct);
$tbl_name = "postcode_location";
$adjacents = 3;
$sql_search_view1 = "SELECT * FROM postcode_location INNER JOIN ad_title_description ON ad_title_description.postcode_loaction_id = postcode_location.id WHERE postcode_location.status ='1' AND postcode_location.{$df}=" . $sub_cat_id . " AND postcode_location.id !=" . $newpostid;
//$sub_cat_id;
$total_pages = mysql_query($sql_search_view1);
$total_num_rows = mysql_num_rows($total_pages);
$total_pages = $total_num_rows;
$page = !empty($_GET['page']) ? $_GET['page'] : 1;
// Setting a default value to the page
$per_page = 10;
// message to show per page
$pagination = new Pagination($page, $per_page, $total_num_rows);
// create an object of clas agination
// end of pagination default variables
$sql_search_view = "SELECT * FROM postcode_location INNER JOIN ad_title_description ON ad_title_description.postcode_loaction_id = postcode_location.id WHERE postcode_location.status ='1' AND postcode_location.{$df}=" . $sub_cat_id . " AND postcode_location.id !=" . $newpostid . " LIMIT {$per_page} OFFSET {$pagination->offset()}";
$result_search_view = mysql_query($sql_search_view);
$num_rows_views = mysql_num_rows($result_search_view);
if ($num_rows_views > 0) {
while ($row_search_view = mysql_fetch_array($result_search_view)) {
$user_id = $row_search_view['user_id'];
$post_id = $row_search_view['postcode_loaction_id'];
$published_date = $row_search_view['date'];
$town = $row_search_view['town'];
$daysago = (strtotime($cdate) - strtotime($published_date)) / (60 * 60 * 24);
$select_image_query = "SELECT postcode_loaction_id,file_name FROM users_images WHERE postcode_loaction_id='" . $post_id . "' ";
$run_image_query = mysql_query($select_image_query);
$fetch_image_query = mysql_fetch_array($run_image_query);
$image_name = $fetch_image_query['file_name'];
//End Image//
$title = $row_search_view['title'];
示例15: substr
<?php
require_once $libpath = substr(str_replace('\\', '/', __DIR__), 0, -28) . 'library/initialize.php';
if (!$session->is_logged_in()) {
redirect_to(HOME . "login");
}
// 1. the current page number ($current_page)
$page = !empty($_GET['page']) ? (int) htmlspecialchars($_GET['page']) : 1;
// 2. records per page ($per_page)
$per_page = 7;
// 3. Find the total count of ads/photos/products
$ads = Product::find_by_field("user_id", $_SESSION['user_id']);
$total_count = 0;
if ($ads) {
foreach ($ads as $ad) {
$total_count++;
}
} else {
$ads = [];
}
$pagination = new Pagination($page, $per_page, $total_count);
$products = Product::find_by_field("user_id", $_SESSION['user_id'], ["limit" => $per_page, "offset" => $pagination->offset()]);
if (!$products) {
$products = [];
}
include $dir_admin . 'dashboard.php';