2017 © Pedro PelĂĄez
 

yii2-extension yii2-helpers

A collection of Yii2 helpers with a variety of purposes

image

jlorente/yii2-helpers

A collection of Yii2 helpers with a variety of purposes

  • Thursday, February 9, 2017
  • by jlorente
  • Repository
  • 1 Watchers
  • 0 Stars
  • 32 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 7 % Grown

The README.md

Yii2 Helpers

A collection of Yii2 helpers with a variety of purposes, (*1)

Included helpers:

QueryStreamIterator - Provides an Iterator for large query resultsets that are likely to spend a large amount of memory., (*2)

Installation

Include the package as dependency under the bower.json file., (*3)

To install, either run, (*4)

$ php composer.phar require jlorente/yii2-helpers "*"

or add, (*5)

...
    "require": {
        // ... other configurations ...
        "jlorente/yii2-helpers": "*"
    }

to the require section of your composer.json file., (*6)

Usage

QueryStreamIterator

Imagine you have a table of cities with 1000000 rows and you want to iterate over all of them. Performing a normal query you will fetch 1000000 results at the same time and the memory consumption will increase., (*7)

This iterator allows you to wrap a QueryInterface object inside it and iterate over the whole resultset, but only fetching the number of results that you establish at the same time., (*8)

i.e.:, (*9)

use jlorente\helpers\QueryStreamIterator;

$cities = new QueryStreamIterator([
    'query' => City::find(),
    'dataStreamSize' => 500
]);
foreach ($cities as $city) {
    echo $city->name . PHP_EOL;
}

Where the query property is the QueryInterface object and the dataStreamSize is number of results to fetch at the same time. You have to consider that the higher this number is, the higher the Iteration speed, but the memory comsumption will be also higher and vice versa., (*10)

License

Copyright © 2015 José Lorente Martín jose.lorente.martin@gmail.com. Licensed under the MIT license. See LICENSE.txt for details., (*11)

The Versions

09/02 2017

dev-master

9999999-dev https://github.com/jlorente/yii2-helpers

A collection of Yii2 helpers with a variety of purposes

  Sources   Download

MIT

by Jose Lorente Martin

helpers collection yii2 helper iterator