jlorente/yii2-helpers 问题修复 & 功能扩展

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

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

jlorente/yii2-helpers

Composer 安装命令:

composer require jlorente/yii2-helpers

包简介

A collection of Yii2 helpers with a variety of purposes

README 文档

README

A collection of Yii2 helpers with a variety of purposes

Included helpers:

QueryStreamIterator - Provides an Iterator for large query resultsets that are likely to spend a large amount of memory.

Installation

Include the package as dependency under the bower.json file.

To install, either run

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

or add

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

to the require section of your composer.json file.

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.

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.

i.e.:

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.

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-08