Opensource ByJG GitHub source GitHub license GitHub release SensioLabsInsight Scrutinizer Code Quality Build Status Code Coverage

Anydataset Core Module. Anydataset is an agnostic data source abstraction layer in PHP.


  • Access different data sources using the same interface.
  • Iterable results
  • Convert results to array

Current Implementations

Object Data Source Read Write Reference
DbDriverInterface Relational DB yes yes Github
AnyDataSet Anydataset yes yes Github
ArrayDataSet Array yes no Github
TextFileDataSet Delimited Fields yes no Github
FixedTextFileDataSet Fixed Size fields yes no Github
XmlDataSet Xml yes no Github
JSONDataSet Json yes no Github
SparQLDataSet SparQl Repositories yes no Github
NoSqlDocumentInterface NoSql Document Based yes yes Github
KeyValueInterface NoSql Key/Value Based yes yes Github


Iterating with foreach

$dataset = new \ByJG\AnyDataset\Core\AnyDataset("example");

$iterator = $dataset->getIterator();
foreach ($iterator as $row) {
    print $row->toArray();

Filtering results

$filter = new \ByJG\AnyDataset\Core\IteratorFilter();
$filter->addRelation("field1", \ByJG\AnyDataset\Core\Enum\Relation::EQUAL, 10);
$iterator2 = $dataset->getIterator($filter);

Conveting to Array

$iterator = $dataset->getIterator();

Iterating with While

$iterator = $dataset->getIterator();
while ($iterator->hasNext()) {
    $row = $iterator->moveNext();


Just type: composer require "byjg/anydataset=4.0.*"

Running Unit tests


Open source ByJG