本文整理汇总了PHP中Paginate::total_pages方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginate::total_pages方法的具体用法?PHP Paginate::total_pages怎么用?PHP Paginate::total_pages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paginate
的用法示例。
在下文中一共展示了Paginate::total_pages方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: count
<?php
$photos = Photo::find_all();
?>
<!-- Navigation -->
<?php
include "includes/navigation.php";
?>
<?php
$page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
$items_per_page = 4;
$total_items = count($photos);
$paginate = new Paginate($page, $items_per_page, $total_items);
$sql = "SELECT * FROM photos LIMIT {$items_per_page} OFFSET {$paginate->offset()}";
$photos = Photo::find_this_query($sql);
$total_pages = $paginate->total_pages();
?>
<!-- Page Content -->
<div class="container">
<div class="row">
<div class="jumbotron">
<h1>Welcome!</h1>
</div>
<div class="col-md-12">
<div class="thumbnails row">
<?php
foreach ($photos as $photo) {
$id = $photo->photo_id;
$photo_title = $photo->title;
$photo_path = $photo->image_path();
示例2: paginate_total_pages
function paginate_total_pages()
{
return Paginate::total_pages();
}
示例3: ceil
/**
* Count total pages on last find
*
* @return int
*/
static function total_pages()
{
if (!empty(self::$total_pages)) {
return self::$total_pages;
}
return self::$total_pages = ceil(self::total_records() / self::limit());
}