phalcon几种分页方法
phalcon几种分页方法
一:
use Phalcon\Paginator\Adapter\Model as PaginatorModel; // Current page to show
// In a controller this can be:
// $this->request->getQuery('page', 'int'); // GET
// $this->request->getPost('page', 'int'); // POST
$currentPage = (int) $_GET["page"]; // The data set to paginate
$robots = Robots::find(); // Create a Model paginator, show 10 rows by page starting from $currentPage
$paginator = new PaginatorModel(
array(
"data" => $robots,
"limit" => 10,
"page" => $currentPage
)
); // Get the paginated results
$page = $paginator->getPaginate();
二:
use Phalcon\Paginator\Adapter\Model as PaginatorModel;
use Phalcon\Paginator\Adapter\NativeArray as PaginatorArray;
use Phalcon\Paginator\Adapter\QueryBuilder as PaginatorQueryBuilder; // Passing a resultset as data
$paginator = new PaginatorModel(
array(
"data" => Products::find(),
"limit" => 10,
"page" => $currentPage
)
); // Passing an array as data
$paginator = new PaginatorArray(
array(
"data" => array(
array('id' => 1, 'name' => 'Artichoke'),
array('id' => 2, 'name' => 'Carrots'),
array('id' => 3, 'name' => 'Beet'),
array('id' => 4, 'name' => 'Lettuce'),
array('id' => 5, 'name' => '')
),
"limit" => 2,
"page" => $currentPage
)
); // Passing a QueryBuilder as data $builder = $this->modelsManager->createBuilder()
->columns('id, name')
->from('Robots')
->orderBy('name'); $paginator = new PaginatorQueryBuilder(
array(
"builder" => $builder,
"limit" => 20,
"page" => 1
)
);
基于模糊查找的分页:
$builder = $this->modelsManager->createBuilder()
->columns("SysCustomer.cus_id,SysCustomer.man_id,SysCustomer.company_name,SysCustomer.contact_name,SysCustomer.mobile,SysCustomer.serv_status,
COUNT(DISTINCT SysCustApp.app_id ) as appcode_num,
COUNT(DISTINCT SysCustAppAirport.airport_code) as airport_num")
->from("SysCustomer")
->leftJoin("SysCustApp", "SysCustApp.cus_id = SysCustomer.cus_id")
->leftJoin("SysCustAppAirport", "SysCustAppAirport.cus_id = SysCustApp.cus_id");
if(!empty($param))
{
$builder ->where($where, array("company" => '%'.$param.'%', "contact"=>'%'.$param.'%', "mobile"=>'%'.$param.'%'));
}else{
$builder ->where($where);
}
$builder->groupBy("SysCustomer.cus_id"); $paginator = new PaginatorQueryBuilder(
array(
'builder'=>$builder,
'limit' =>10,
'page' =>$currentPage
)
);
phalcon几种分页方法的更多相关文章
- PostgreSQL两种分页方法查询时间比较
数据库中存了3000W条数据,两种分页查询测试时间 第一种 SELECT * FROM test_table WHERE i_id> limit 100; Time: 0.016s 第二种 SE ...
- java oracle的2种分页方法
java oracle的2种分页方法 一物理分页: <!-- 分页查询所有的博客信息 --> <select id="findBlogs" resultType= ...
- sql server两种分页方法
方法一: --分页方法一 OrderID,CustomerID, EmployeeID,OrderDate,ShippedDate,ShipName,ShipAddress,Freight from ...
- MVC三种分页方法
View部分: @using WebApplication1.Models;分页方法1引包 @*@using PagedList.Mvc; @using WebApplication1.Models; ...
- 数据分页 THINKPHP3.2 分页 三种分页方法
数据分页 复制本页链接 opensns 通常在数据查询后都会对数据集进行分页操作,ThinkPHP也提供了分页类来对数据分页提供支持. 下面是数据分页的两种示例. 第一种:利用Page类和limit方 ...
- Sql三种分页方法
--分页三种方法--第一种 ROW_NUMBER() OVER( ORDER BY OrgID) AS indexs 大于pagesize*pageindex,少于等于pagesize*(pagein ...
- sqlalchemy和flask-sqlalchemy的几种分页方法
sqlalchemy中使用query查询,而flask-sqlalchemy中使用basequery查询,他们是子类与父类的关系 假设 page_index=1,page_size=10:所有分页查询 ...
- aspnetpager的2种分页方法
<webdiyer:AspNetPager ID="AspNetPager1" UrlPaging="True" PageSize="20&qu ...
- sqlserver两种分页方法比较
-- 3000 page(从1开始) 10 pagesize -- 方法1(效率不高): SELECT TOP 10 * FROM [xxx].[oooo] WHERE id NOT IN (SELE ...
随机推荐
- CurrentHashMap的实现原理
转载:http://wiki.jikexueyuan.com/project/java-collection/concurrenthashmap.html 概述 我们在之前的博文中了解到关于 Hash ...
- Callable, Runnable, Future, FutureTask
Java并发编程之Callable, Runnable, Future, FutureTask Java中存在Callable, Runnable, Future, FutureTask这几个与线程相 ...
- fullPage.js
https://github.com/alvarotrigo/fullPage.js 下载地址 demo:http://pan.baidu.com/s/1o8QWCmm 演示:http://full ...
- HDU 1004 Let the Balloon Rise map
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- PHP判断用户设备是否是移动设备
摘自http://www.oschina.net/code/snippet_1432190_46913 <?php function isMobile() { // 如果有HTTP_X_WA ...
- linux内核中的GPIO系统之(1):软件框架
一.前言 作为一个工作多年的系统工程师,免不了做两件事情:培训新员工和给新员工分配任务.对于那些刚刚从学校出来的学生,一般在开始的时候总是分配一些非常简单的任务,例如GPIO driver.LED d ...
- :判断101-200之间有多少个素数,并输出所有素数。 程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除, 则表明此数不是素数,反之是素数。
package C; public class Sushu { public static void main(String[] args) { int sum=0; for (int i = 101 ...
- c++ 动态分配二维数组 new 二维数组
#include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _T ...
- ubuntu12.04安装mysql
首先下载ubuntu 12.04 64位对应的myqsl版本 http://dev.mysql.com/downloads/file/?id=464508 然后按照如下 ...
- linux的计划任务crontab
crontab(全称cron table计划任务列表)是一个用于周期性被执行的任的工具. 相关指令: usage: crontab [-u user] file crontab [ -u user ...