Matters proposal usage of zend-repository
<?php
class TableRepository extends \Matters\Repository {
public function findAllByName(string $name)
{
$select = $this->select();
$select->where
->equalTo([
'name' => $name,
]);
$select->order(['created_at' => 'DESC']);
return $this->fetchListEntities($select);
}
}
<?php
$hydratingResultSet = new \Zend\Db\ResultSet\HydratingResultSet(
new Hydrator(),
new Model()
);
$tableGateway = new \Zend\Db\TableGateway\TableGateway(
'table_name',
new \Zend\Db\Adapter\Adapter($config),
null,
$hydratingResultSet
);
$tableRepository = new TableRepository($tableGateway);
$entities = $tableRepository->findAllByName('Bob');
./vendor/bin/phpunit tests