I have a DB table Entity
and a corresponding DTO class Entity
(no constructor arguments).
When I do this:
$entity=$connection->query("Select * FROM Entity WHERE id='1'",
PDO::FETCH_CLASS,
'Entity',
NULL);
Then $entity
is a PDOStatement
containing one object of class Entity
.
How can I retrieve this one Entity object without looping over $entity
with a foreach
?
PDOStatment:fetchObject
didn't seem like a good solution, because it's going to map the Entity
object in the PDOStatement
on a new Entity
object.