Im using Doctrine 2 ORM in my Zend project and need to serialize my Entities to JSON in several cases.
ATM i use the Querybuilder and join all tables i need. But my
When using Doctrine's query builder, you can't disable lazy loading of linked model classes. If you want to bypass such behavior, you better have to request data with Doctrine's DBAL.
Don't use \Doctrine\ORM\QueryBuilder but \Doctrine\DBAL\Query\QueryBuilder.
$qb = new QueryBuilder($this->_em->getConnection());
$expr = $qb->expr();
$qb->select('pa.*', 't.*', 'c.*', 'a.*', 'aps.*', 'apt.*', 'p.*')
->from('person_appointment', 'pa')
->leftJoin('pa', 'table', 't', $expr->eq('pa.table_id', 't.table_id'))
// put other joints here
// ...
->leftjoin('a', 'person', 'p', $expr->eq('a.person_id', 'p.person_id'));