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


PHP Pagination::pagination方法代码示例

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


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

示例1: getAll

 /**
  * get all news feed.
  *
  * @access public
  * @param  integer  $pageNum
  * @return array
  *
  */
 public function getAll($pageNum = 1)
 {
     $pagination = Pagination::pagination("newsfeed", "", [], $pageNum);
     $offset = $pagination->getOffset();
     $limit = $pagination->perPage;
     $database = Database::openConnection();
     $query = "SELECT newsfeed.id AS id, users.profile_picture, users.id AS user_id, users.name AS user_name, newsfeed.content, newsfeed.date ";
     $query .= "FROM users, newsfeed ";
     $query .= "WHERE users.id = newsfeed.user_id ";
     $query .= "ORDER BY newsfeed.date DESC ";
     $query .= "LIMIT {$limit} OFFSET {$offset}";
     $database->prepare($query);
     $database->execute();
     $newsfeed = $database->fetchAllAssociative();
     return array("newsfeed" => $newsfeed, "pagination" => $pagination);
 }
开发者ID:mrSerg161,项目名称:miniPHP,代码行数:24,代码来源:NewsFeed.php

示例2: getAll

 /**
  * get all posts
  *
  * @access public
  * @param  integer  $pageNum
  * @return array    Associative array of the posts, and Pagination Object.
  *
  */
 public function getAll($pageNum = 1)
 {
     $pagination = Pagination::pagination("posts", "", [], $pageNum);
     $offset = $pagination->getOffset();
     $limit = $pagination->perPage;
     $database = Database::openConnection();
     $query = "SELECT posts.id AS id, users.profile_picture, users.id AS user_id, users.name AS user_name, posts.title, posts.content, posts.date ";
     $query .= "FROM users, posts ";
     $query .= "WHERE users.id = posts.user_id ";
     $query .= "ORDER BY posts.date DESC ";
     $query .= "LIMIT {$limit} OFFSET {$offset}";
     $database->prepare($query);
     $database->execute();
     $posts = $database->fetchAllAssociative();
     $this->appendNumberOfComments($posts, $database);
     return array("posts" => $posts, "pagination" => $pagination);
 }
开发者ID:reallysend,项目名称:miniPHP,代码行数:25,代码来源:Post.php

示例3: getAll

 /**
  * get all files.
  *
  * @access public
  * @param  integer  $pageNum
  * @return array
  *
  */
 public function getAll($pageNum = 1)
 {
     //get pagination object
     $pagination = Pagination::pagination("files", "", [], $pageNum);
     $offset = $pagination->getOffset();
     $limit = $pagination->perPage;
     $database = Database::openConnection();
     $query = "SELECT files.id AS id, files.filename, users.id AS user_id, users.name AS user_name, files.extension AS format, files.hashed_filename, files.date ";
     $query .= "FROM users, files ";
     $query .= "WHERE users.id = files.user_id ";
     $query .= "ORDER BY files.date DESC ";
     $query .= "LIMIT {$limit} OFFSET {$offset}";
     $database->prepare($query);
     $database->execute();
     $files = $database->fetchAllAssociative();
     return array("files" => $files, "pagination" => $pagination);
 }
开发者ID:reallysend,项目名称:miniPHP,代码行数:25,代码来源:File.php

示例4: getUsers

 /**
  * get all users in the database
  *
  * @access public
  * @param  string  $name
  * @param  string  $email
  * @param  string  $role
  * @param  integer $pageNum
  * @return array
  *
  */
 public function getUsers($name = null, $email = null, $role = null, $pageNum = 1)
 {
     //validate user inputs
     $validation = new Validation();
     if (!$validation->validate(['User Name' => [$name, 'alphaNumWithSpaces|maxLen(30)'], 'Email' => [$email, 'email|maxLen(50)'], 'Role' => [$role, 'inArray(admin, user)']])) {
         $this->errors = $validation->errors();
         return false;
     }
     //in $options array, add all possible values from user, and their name parameters
     //then applyOptions() method will see if value is not empty, then add it to our query
     $options = [$name => "name = :name ", $email => "email = :email ", $role => "role = :role "];
     //get options query
     $options = $this->applyOptions($options, "AND ");
     $options = empty($options) ? "" : "WHERE " . $options;
     $values = [];
     if (!empty($name)) {
         $values[":name"] = $name;
     }
     if (!empty($email)) {
         $values[":email"] = $email;
     }
     if (!empty($role)) {
         $values[":role"] = $role;
     }
     //get pagination object so that we can add offset and limit in our query
     $pagination = Pagination::pagination("users", $options, $values, $pageNum);
     $offset = $pagination->getOffset();
     $limit = $pagination->perPage;
     $database = Database::openConnection();
     $query = "SELECT id, name, email, role, is_email_activated FROM users ";
     $query .= $options;
     $query .= "LIMIT {$limit} OFFSET {$offset}";
     $database->prepare($query);
     $database->execute($values);
     $users = $database->fetchAllAssociative();
     return array("users" => $users, "pagination" => $pagination);
 }
开发者ID:reallysend,项目名称:miniPHP,代码行数:48,代码来源:Admin.php

示例5: getAll

 /**
  * get all comments of a post
  *
  * @access public
  * @param  array     $postId
  * @param  integer   $pageNum
  * @param  integer   $commentsCreated
  * @return array    Associative array of the comments, and Pagination Object(View More).
  *
  */
 public function getAll($postId, $pageNum = 1, $commentsCreated = 0)
 {
     //Only for comments, We use $commentsCreated
     //What's it? Whenever we create a comment, It will be added in-place to the current comments in current .php page,
     //So, we need to track of those were created, and skip them in the Pagination($offset & $totalCount).
     $options = "WHERE comments.post_id = :post_id ";
     $pagination = Pagination::pagination("comments", $options, [":post_id" => $postId], $pageNum, $commentsCreated);
     $offset = $pagination->getOffset() + $commentsCreated;
     $limit = $pagination->perPage;
     $database = Database::openConnection();
     $query = "SELECT comments.id AS id, users.profile_picture, users.id AS user_id, users.name AS user_name, comments.content, comments.date ";
     $query .= "FROM users, posts, comments ";
     $query .= "WHERE comments.post_id = :post_id ";
     $query .= "AND posts.id = comments.post_id ";
     $query .= "AND users.id = comments.user_id ";
     $query .= "ORDER BY comments.date DESC ";
     $query .= "LIMIT {$limit} OFFSET {$offset}";
     $database->prepare($query);
     $database->bindValue(':post_id', (int) $postId);
     $database->execute();
     $comments = $database->fetchAllAssociative();
     //you can have post with no comments yet!
     return array("comments" => $comments, "pagination" => $pagination);
 }
开发者ID:reallysend,项目名称:miniPHP,代码行数:34,代码来源:Comment.php

示例6: Pagination

<?php

$obj = new Pagination();
$data = $obj->pagination();
?>
	<h1 class="courses_title">Popular courses</h1>
	<!-- courses section  -->

	<div class="course-list">
		<!-- course first section  -->
        <?php 
if (isset($data) && !empty($data)) {
    $i = 0;
    foreach ($data as $row) {
        $i++;
        if ($i == 5) {
            break;
        }
        ?>
		<div class = "column <?php 
        if ($i % 4 == 0) {
            echo 'last';
        }
        ?>
">
			<div class="column-content">
				<!-- course first section img -->
				<div class="col-img">
					<a href="course_info.php?id=<?php 
        echo $row->id;
        ?>
开发者ID:raulrene,项目名称:sfaw-test,代码行数:31,代码来源:courses.php

示例7: Pagination

<div class="course-list">
    <!-- course first section  -->
    <?php 
$obj = new Pagination();
$q = $obj->pagination();
if (isset($q) && !empty($q)) {
    $i = 0;
    foreach ($q as $row) {
        $i++;
        ?>
            <div class = "column <?php 
        if ($i % 4 == 0) {
            echo "last";
        }
        ?>
">
                <div class="column-content">
                    <!-- course first section img -->
                    <div class="col-img">
                        <a href="course_info.php?id=<?php 
        echo $row->id;
        ?>
">
                            <img src="<?php 
        echo $row->course_img;
        ?>
" alt="<?php 
        echo $row->img_alt;
        ?>
" />
                        </a>
开发者ID:raulrene,项目名称:sfaw-test,代码行数:31,代码来源:course_loop1.php

示例8: Course

<?php

$obj = new Course();
$data = $obj->getAll();
$pag = new Pagination();
$dataPag = $pag->pagination();
?>

<div class="row">
    <h1>Courses</h1>
</div>

<div class="course-list">
    <?php 
if (isset($dataPag) && !empty($dataPag)) {
    $no = 0;
    foreach ($dataPag as $row) {
        $no++;
        ?>
            <div class = "column <?php 
        if ($no % 4 == 0) {
            echo "last";
        }
        ?>
">
                <div class="column-content">
                    <!-- course first section img -->
                    <div class="col-img">
                        <a href="course-info.php?id=<?php 
        echo $row->id;
        ?>
开发者ID:raulrene,项目名称:sfaw-test,代码行数:31,代码来源:courses-loop1.php


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