当前位置: 首页>>代码示例>>PHP>>正文


PHP Photograph::count_all方法代码示例

本文整理汇总了PHP中Photograph::count_all方法的典型用法代码示例。如果您正苦于以下问题:PHP Photograph::count_all方法的具体用法?PHP Photograph::count_all怎么用?PHP Photograph::count_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Photograph的用法示例。


在下文中一共展示了Photograph::count_all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Pagination

<?php

require_once "../includes/initialize.php";
// 1. the current page number ($current_page)
$page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
// 2. records per page ($per_page)
$per_page = 3;
// 3. total record count ($total_count)
$total_count = Photograph::count_all();
// Find all photos
// use pagination instead
//$photos = Photograph::find_all();
$pagination = new Pagination($page, $per_page, $total_count);
// Instead of finding all records, just find the records
// for this page
$sql = "SELECT * FROM photographs ";
$sql .= "LIMIT {$per_page} ";
$sql .= "OFFSET {$pagination->offset()}";
$photos = Photograph::find_by_sql($sql);
// Need to add ?page=$page to all links we want to
// maintain the current page (or store $page in $session)
?>

<?php 
include_layout_template('header.php');
?>

<?php 
foreach ($photos as $photo) {
    ?>
  <div style="float: left; margin-left: 20px;">
开发者ID:raynaldmo,项目名称:php-education,代码行数:31,代码来源:index.php

示例2: output_message

<?php

require_once "../includes/initialize.php";
/**
 * First I need to get the page number and in the event it is empty, like on
 * first getting to the site.
 * @var int
 */
$page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
$per_page = 5;
$count = Photograph::count_all();
// $photos = Photograph::find_all();
$pagination = new Pagination($page, $per_page, $count);
$sql = $pagination->build_sql("photographs");
$photos = Photograph::find_by_sql($sql);
?>

<?php 
include_layout_template("header.php");
?>

<h2>Photographs</h2>
<?php 
echo output_message($message);
?>
<div>
    <?php 
foreach ($photos as $photo) {
    ?>
    <div id="photo">
        <figure>
开发者ID:natac13,项目名称:PHP-Advanced-OOP-project-MySQL,代码行数:31,代码来源:index.php


注:本文中的Photograph::count_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。