Skip to content

Commit d06f148

Browse files
author
imota
committed
close() function on both iterators, to avoid NativePdoIterator connection leaks.
1 parent 1df2278 commit d06f148

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/Iterator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
interface Iterator extends \Countable, \Traversable
66
{
7+
public function close();
78
}

src/LimitIterator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,9 @@ protected function loadCount()
180180
->fetch(\PDO::FETCH_ASSOC);
181181
$this->rowCount = $row['FOUND_ROWS'];
182182
}
183+
184+
public function close()
185+
{
186+
$this->pdo = null;
187+
}
183188
}

src/NativePDOIterator.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ public function count()
1414
{
1515
return $this->rowCount();
1616
}
17+
18+
public function close()
19+
{
20+
parent::closeCursor();
21+
$this->pdo = null;
22+
}
1723
}

0 commit comments

Comments
 (0)