I have a PostMapper class like the one in http://www.sitepoint.com/integrating-the-data-mappers/
But, I modified the find method, so it can have more parameters (I want to paginate the data, so I added the limit parameter)
public function find(array $columns = array('*'), array $where = array(), $offset=0, $limit=5, $orderBy=null) {
$sql = new SQLStatement();
$sql->select($columns, 'post');
if (!empty($where)) {
$sql->where($where);
}
if (isset($orderBy)) {
$sql->orderBy($orderBy);
}
$sql->limit($offset, $limit);
$rows = $this->dbh->query($sql)->fetchAll();
$this->createEntity($rows);
}
Is my code good ?
Is it overkill to use object for SQLStatement instead of just using string ?
Does it violate the Single Responsibility Principle because it generates the SQLStatement Object ?
Could you please tell me if there is a better way ?