Skip to content

Commit 2cc63a7

Browse files
author
Robert Pustułka
committed
Create README.md
Simple readme.
1 parent 127e0a2 commit 2cc63a7

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,43 @@
1-
# cakephp-chunk
1+
# CakePHP Chunk plugin
2+
3+
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
4+
[![Build Status](https://travis-ci.org/robotusers/cakephp-chunk.svg?branch=master)](https://travis-ci.org/robotusers/cakephp-chunk)
5+
[![codecov](https://codecov.io/gh/robotusers/cakephp-chunk/branch/master/graph/badge.svg)](https://codecov.io/gh/robotusers/cakephp-chunk)
6+
7+
This plugin allows to chunk results retrieved from a database in order to save memory.
8+
9+
## Installation
10+
11+
```
12+
composer require robotusers/cakephp-chunk
13+
bin/cake plugin load Robotusers/Chunk
14+
```
15+
16+
## Using the plugin
17+
18+
The plugin provides a custom `ResultSet` class which accepts `Cake\ORM\Query` instance.
19+
20+
Example:
21+
```php
22+
$query = $table->find();
23+
$results = new \Robotusers\Chunk\Model\ResultSet($query);
24+
25+
foreach ($results as $result) {
26+
// do stuff
27+
}
28+
```
29+
30+
You can control how many elements are in one "chunk" (1000 by default):
31+
32+
```php
33+
$query = $table->find();
34+
$results = new \Robotusers\Chunk\Model\ResultSet($query, ['size' => 100]);
35+
```
36+
37+
The plugin provides also a behavior with `chunk()` method:
38+
39+
```php
40+
$table->addBehavior('Robotusers/Chunk.Chunk');
41+
$query = $table->find();
42+
$results = $table->chunk($query, ['size' => 100]);
43+
```

0 commit comments

Comments
 (0)