I'm building a small project with Symfony 2.6. Its very simple with only one entity class which maps to data inserted into a MySQL database using python running on a Raspberry Pi.
Problem
when I run this simple repository query the result set is seemingly being converted to an array which is causing the an error (below). I'm not sure why this conversion is happening.
Repo method
public function getDataInRange( \DateTime $from, \DateTime $until)
{
$query = $this->getEntityManager()->createQuery('
select d
from AppBundle:weatherdata d
where d.idx > :f
and d.idx < :u ')->setParameters(array( 'f' => $from, 'u' => $until ));
return $query->getResult();
}
Error
Catchable Fatal Error: Object of class DateTime could not be converted to string
Database structure
the main primary key, 'idx' is a datetime
object, everything else is double
.
Have tried..
I've tried altering the repo method to return getArrayResult()
instead, which stops the error, but I need the result set to be in object format because of other messing about that I need to do to the data.
Thanks in advance.