criativamos/paginator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

criativamos/paginator

Composer 安装命令:

composer require criativamos/paginator

包简介

A simple PHP library to create pagination

README 文档

README

A simple PHP library to create pagination.

Installation

$ composer require criativamos/paginator

How to use

You can see the full implementation in example.php Do not forget to create the test database mock_data.sql

$query = "SELECT * FROM mock_data"
//the first parameter is a PDO instance with database connection
//the third parameter is the number of items per page. The default value is 15
$pg = new \Criativamos\Paginator\Paginator($pdoconnection, $query, 10);
//print result
if($pg->rowCount() > 0){
    foreach ($pg->getData() as $data){
        echo '<tr>';
        echo '<td>'.$data->id.'</td>';
        echo '<td>'.$data->first_name.'</td>';
        echo '<td>'.$data->last_name.'</td>';
        echo '<td>'.$data->email.'</td>';
        echo '</tr>';
    }
}
...
//pagination
$pg->render();

Query with parameters

$query = "SELECT * FROM mock_data WHERE LOWER (first_name) LIKE :SEARCH";
$pg = new \Criativamos\Paginator\Paginator($pdoconnection, $query);
$pg->setParameters([
    ':SEARCH' => '%jo%'
]);

You can do the same like this

$query = "SELECT * FROM mock_data WHERE LOWER (first_name) LIKE :SEARCH";
$pg = new \Criativamos\Paginator\Paginator($pdoconnection);
$pg->setQuery($query, [
    ':SEARCH' => '%jo%'
]);

Get detailed results

$query = "SELECT * FROM mock_data"
$pg = new \Criativamos\Paginator\Paginator($pdoconnection, $query);
print_r( $pg->results() );

Output

Array
(
    [currentPage] => 1
    [total] => 200
    [perPage] => 10
    [lastPage] => 19
    [nextPageUrl] => http://localhost/lab/pagination/example.php?page=2
    [prevPageUrl] => http://localhost/lab/pagination/example.php
    [currentUrl] => http://localhost/lab/pagination/example.php
    [from] => 1
    [to] => 10
    [data] => Array
        (
            ...
        )
)            
        

统计信息

  • 总下载量: 61
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固