2017 © Pedro Peláez
 

yii2-extension yii2-dbtable-iterate

iterate rows from table

image

postor/yii2-dbtable-iterate

iterate rows from table

  • Thursday, April 7, 2016
  • by postor
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

yii2-dbtable-iterate

iterate rows from table, specially for big tables that will cause php memory limit error., (*1)

遍历数据库表,尤其是会导致php内存错误的大表, (*2)

Installation安装步骤:

The preferred way to install this extension is through composer.推荐使用composer, (*3)

Either run命令行输入并运行, (*4)

php composer.phar require "postor/yii2-dbtable-iterate" "*"

or add或者在配置文件composer.json中添加, (*5)

"postor/yii2-dbtable-iterate": "*"

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

Usage使用方法:


// commands/HelloController.php namespace app\commands; use app\models\Article; use postor\dbtableiterate\DbTableIterate; use yii\console\Controller; class HelloController extends Controller { public function actionIndex() { new DbTableIterate(Article::find()->offset(3)->limit(5),function($row){ echo $row->id.','; },3); } }

result 效果:


F:\xampp\htdocs\yii2postor\1>yii hello 1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, F:\xampp\htdocs\yii2postor\1>yii hello 1,3,4,5,6, F:\xampp\htdocs\yii2postor\1>yii hello 5,6,7,8,9,

params 参数说明:

ActiveQuery $query: the query to get rows取数据的查询, (*7)

function $callback: each row will be pass into it查出来的每行都会传入这个回调, (*8)

int pageSize: get pageSize rows from db each time每次从数据库取出这么多, (*9)

The Versions

07/04 2016

dev-master

9999999-dev

iterate rows from table

  Sources   Download

BSD-3-Clause

The Requires

 

by LinYanjun

yii2 table yii 2 iterate

07/04 2016

1.0

1.0.0.0

iterate rows from table

  Sources   Download

BSD-3-Clause

The Requires

 

by LinYanjun

yii2 table yii 2 iterate