Skip to content

Commit a06c6f8

Browse files
committed
update Eloquent to support lazy call beside cursor
1 parent faabe89 commit a06c6f8

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Version 2.1.0
44

5-
1. Add retrieving method for `Eloquent` in query method, support `lazy` call.
5+
1. Add retrieving option for `Eloquent` in query method, support `lazy` call.
66

77
## Version 2.0.0
88

Eloquent.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Eloquent extends \koolreport\core\DataSource
1212
* @param mixed $builder
1313
*/
1414
protected $builder;
15-
protected $retrievingMethod;
15+
protected $retrievingMethod = null;
1616

1717
public function query($builder, $retrievingMethod = null)
1818
{
@@ -23,21 +23,21 @@ public function query($builder, $retrievingMethod = null)
2323

2424
public function sendMetaAndItem($metaData, $item)
2525
{
26-
if(!$metaData)
26+
if(!$metaData)
27+
{
28+
$metaData = array(
29+
"columns"=>array()
30+
);
31+
foreach($item->toArray() as $k=>$v)
2732
{
28-
$metaData = array(
29-
"columns"=>array()
33+
$metaData["columns"][$k] = array(
34+
"type"=>Utility::guessType($v)
3035
);
31-
foreach($item->toArray() as $k=>$v)
32-
{
33-
$metaData["columns"][$k] = array(
34-
"type"=>Utility::guessType($v)
35-
);
36-
}
37-
$this->sendMeta($metaData, $this);
38-
$this->startInput(null);
3936
}
40-
$this->next($item->toArray(), $this);
37+
$this->sendMeta($metaData, $this);
38+
$this->startInput(null);
39+
}
40+
$this->next($item->toArray(), $this);
4141
}
4242

4343
/**
@@ -53,7 +53,7 @@ public function start()
5353
{
5454
$this->sendMetaAndItem($metaData, $item);
5555
}
56-
} else {
56+
} else if ($this->retrievingMethod == 'cursor' || $this->retrievingMethod == null) {
5757
foreach($this->builder->cursor() as $item)
5858
{
5959
$this->sendMetaAndItem($metaData, $item);

0 commit comments

Comments
 (0)