pavle/yii-batch-result

There is no license information available for the latest version (v1.0.2) of this package.

yii's batch result extension

v1.0.2 2015-12-30 08:08 UTC

This package is not auto-updated.

Last update: 2024-04-27 16:58:15 UTC


README

#Yii1.x 数据分批获取扩展 1.简介: 查询大量的数据库中的数据时,建议您尽可能使用批处理查询,尽量减少您的内存使用情况。

2.安装方式:

composer require pavle/yii-batch-result

3.使用方式:

public function behaviors()
{
    return array(
        array(
            'class' => '\pavle\batch\behaviors\BatchResultBehavior',
            'batchSize' => 20
        ),
    );
}

在需要使用批处理的地方

foreach(Product::model()->batch($condition, $params, $batchSize) as $products){
    //products是一个batchSize数量的数据集
}

foreach(Product::model()->each($condition, $params, $batchSize) as $product){
    //product是一个数据对象
}