auto-count-sql-data-provider AutoCountSqlDataProvider has the ability to use pagination without first counting all the rows, thus increasing performance.

  1. Requirements
  2. Usage
  3. Resources

AutoCountSqlDataProvider extends the CSqlDataProvider. It adds the ability to use pagination without first counting all the rows, thus increasing the performance when browsing large tables.

Requirements

None

Usage

# table_name has 15 rows.

$provider = new AutoCountSqlDataProvider(
	'table_name',
	new CDbCriteria(array('condition'=>'column1 is not null')),
	false,
	array(
		'sort'=>array(
			'attributes'=>array('column1','column2'),
		),
		'pagination'=>array(
			'pageSize'=>10,
		),
	)
);

$rows = $provider->fetchData();
# count($rows) == 10
# $provider->hasMore == true
# $provider->getTotalItemCount() == 10
$rows = $provider->fetchData();
# count($rows) == 5
# $provider->hasMore == false
# $provider->getTotalItemCount() == 15

Resources

3 1
6 followers
627 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Database
Developed by: prekageo
Created on: Jul 21, 2011
Last updated: 13 years ago

Downloads

show all

Related Extensions