I have a UserEntity
where I set some getters
and setters
, ex:
class Users
{
protected $id;
protected $name;
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
}
}
...
then I have a Users
model that has some find()
, fetchAll()
methods:
class Users extends Phalcon\Mvc\Model
{
public function findById($id = NULL)
{
if(!$id) return NULL;
return $this->find($id)->getFirst();
}
What I want is to map those entities with the result from this query.
something like this example from zend:
$entityPrototype = new TaskEntity(); <- this would be my user entity
$hydrator = new ClassMethods(); <- not sure if this exists in Phalcon
$resultset = new HydratingResultSet($hydrator, $entityPrototype); <- do the mapping
$resultset->initialize($results);
return $resultset;
Any ideas?