Integrations PDO into Plum.

v0.1.1 2015-10-06 16:07 UTC

This package is auto-updated.

Last update: 2023-01-20 06:06:45 UTC


PlumPdo integrates PDO into Plum. Plum is a data processing pipeline for PHP.

Build Status Windows Build status Scrutinizer Code Quality Code Coverage StyleCI

Developed by Florian Eckerstorfer in Vienna, Europe.


You can install Plum using Composer.

$ composer require plumphp/plum-pdo


Please refer to the Plum documentation for more information.

Currently PlumPdo contains PdoStatementReader to read data from a PDO-compatible database.


Plum\PlumPdo\PdoStatementReader returns an iterator for the result set of a PDOStatement. The execute() method has to be called before.

use Plum\PlumPdo\PdoStatementReader;

$statement = $pdo->prepare('SELECT * FROM users WHERE age >= :min_age');
$statement->bindValue(':min_age', 18);

$reader = new PdoStatementReader($statement);
$reader->getIterator(); // -> \ArrayIterator

The default behavior shown in the example above is that getIterator() will call fetchAll() on the PDOStatement and returns the result in the form of an \ArrayIterator. However, if the result set is very large and memory becomes a concern it is possible to fetch the result set row by row and yield each row to the workflow. You can invoke the behaviour by setting the option yield to true.

In the following example getIterator() returns a \Generator.

use Plum\PlumPdo\PdoStatementReader;

$statement = $pdo->prepare('SELECT * FROM users WHERE age >= :min_age');
$statement->bindValue(':min_age', 18);

$reader = new PdoStatementReader($statement, ['yield' => true]);
$iterator = $reader->getIterator(); // -> \Generator
foreach ($iterator as $row) {

The downside of using yield is that the reader is no longer countable and when invoking count() on such a reader a \RuntimeException will be thrown.

Change Log

Version 0.1.1 (6 October 2015)

  • Fix Plum version

Version 0.1 (22 April 2015)

  • Initial release


The MIT license applies to plumphp/plum-pdo. For the full copyright and license information, please view the LICENSE file distributed with this source code.