A proposal on how to use laminas/laminas-db
<?php
class TableRepository extends \Storal\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 \Laminas\Db\ResultSet\HydratingResultSet(
new Hydrator(),
new Model()
);
$tableGateway = new \Laminas\Db\TableGateway\TableGateway(
'table_name',
new \Laminas\Db\Adapter\Adapter($config),
null,
$hydratingResultSet
);
$tableRepository = new TableRepository($tableGateway);
$entities = $tableRepository->findAllByName('Bob');
<?php
class TableRepository extends \Storal\Repository {
public function wasCooked()
{
$select = $this->exists();
$select->where->equalTo('is_cooked', true);
return $this->fetchExists($select);
}
}
./vendor/bin/phpunit