I am using the orm doctrine with the admingenerator module from symfony2, and I can’t do a quantity count involving two tables.
I would really appreciate any thoughts on this. Thank you very much in advance!
This is a querybuilder expression :
class ListController extends BaseListController
{
protected function getQuery()
{
$query = $this->getDoctrine()
->getEntityManager()
->createQueryBuilder()
->select('q, count(f.fbid) AS no')
->from('Shlomi\UsersBundle\Entity\users', 'q')
->leftJoin('q.fbid' , 'f')
->groupBy('q.fbid');
$this->processSort($query);
$this->processFilters($query);
$this->processScopes($query);
return $query->getQuery();
}
}
Two objects that I use:
class Users
{
private $id;
private $fbid;
....
AND
class Friendships
{
private $Id;
private $fbid;
....
While the association annotation in Friendships was automatically generated by the doctrine: generate-entities (containing a link to the fbid foreign key from Users.fbid), the annotation in Users (1: n) was manually inserted as far as I know
I tried to edit the query builder and annotation again and again, but in the end I get the following:
( "Catchable Fatal Error: Object of Doctrine\ORM\PersistentCollection C:\xampp\htdocs\symfony2\app\cache\dev\twig\ea\85\2b678090e942db52cc01e3950dbc.php line 225" ) Admingenerated/ShlomiUsersBundle/Resources/views/UsersList/index.html.twig 92.
,