forked from bashkarev/clickhouse
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ActiveQuery.php
39 lines (35 loc) · 935 Bytes
/
ActiveQuery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
* @copyright Copyright (c) 2017 Dmitry Bashkarev
* @license https://github.com/bashkarev/clickhouse/blob/master/LICENSE
* @link https://github.com/bashkarev/clickhouse#readme
*/
namespace bashkarev\clickhouse;
/**
* @method Command createCommand($db)
*
* @author Dmitry Bashkarev <[email protected]>
*/
class ActiveQuery extends \yii\db\ActiveQuery
{
/**
* @inheritdoc
*/
public function each($batchSize = 100, $db = null)
{
foreach ($this->createCommand($db)->queryBatchInternal($batchSize) as $rows) {
foreach ($this->populate($rows) as $key => $model) {
yield $key => $model;
}
}
}
/**
* @inheritdoc
*/
public function batch($batchSize = 100, $db = null)
{
foreach ($this->createCommand($db)->queryBatchInternal($batchSize) as $rows) {
yield $this->populate($rows);
}
}
}