Skip to content

Commit b429825

Browse files
author
imota
committed
2 parents d06f148 + 2f5c683 commit b429825

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ foreach ($iterator as $item) {
4444

4545
Notes
4646
---
47-
The library will throw a InvalidQueryException on non "select" queries.
47+
The factory will throw a InvalidQueryException on non "select" queries.
4848

49-
The library will only return a LimitIterator when:
49+
The factory will only return a LimitIterator when:
5050
* The blockSize is > 0
5151
* The query has an "order by" clause
5252
* The query is not using any "rand()" functions
5353
* The query doesn't already have a "limit" clause.
5454

55-
If any of the previous conditions exist, it will return a non limit based iterator called
55+
If any of the previous conditions are met, the factory will return a non limit based iterator called
5656
"NativePDOIterator".
5757

5858
To ensure consistency among results, you might want to get the whole iteration and count inside a database transaction.

src/Factory.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ public function create(\PDO $adapter, $query, $blockSize)
1212
{
1313
if ($this->queryIsLimitable($query) && $blockSize > 0) {
1414
return new LimitIterator($adapter, $query, $blockSize);
15-
} else {
16-
$adapter->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
17-
$adapter->setAttribute(
18-
\PDO::ATTR_STATEMENT_CLASS,
19-
[NativePDOIterator::class, [$adapter]]
20-
);
21-
/** @var Iterator $statement */
22-
$statement = $adapter->query($query);
23-
return $statement;
2415
}
16+
$adapter->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
17+
$adapter->setAttribute(
18+
\PDO::ATTR_STATEMENT_CLASS,
19+
[NativePDOIterator::class, [$adapter]]
20+
);
21+
/** @var Iterator $statement */
22+
$statement = $adapter->query($query);
23+
return $statement;
2524
}
2625

2726
protected function queryIsLimitable($query) {
@@ -44,4 +43,4 @@ protected function queryHasOrderByClause($query)
4443
{
4544
return (preg_match('/ORDER BY/i', $query));
4645
}
47-
}
46+
}

0 commit comments

Comments
 (0)