[Flow] Find all Objects with an empty Collection
David Sporer
david.sporer at gmail.com
Mon Jan 20 21:57:11 CET 2014
I found it myself after sending the mail :-)It's easy by just usingreturn $query->matching($query->isEmpty('registrations'))->count()
RegardsDavid
> Date: Mon, 20 Jan 2014 21:39:59 +0100
> From: david.sporer at gmail.com
> To: flow at lists.typo3.org
> Subject: Re: [Flow] Find all Objects with an empty Collection
>
> Sorry.. I shouldn't use this Online Tool to format things...
> Hi,
> I have a Model containing an 1:n relationship:
> /**
> * The pushNotificationRegistrations
> * @var
> \Doctrine\Common\Collections\Collection<\My\Project\Domain\Model\Registration>
>
> * @ORM\OneToMany(mappedBy="User")
> */
> protected $registrations;
>
> Is it possible to find all Objects where the count of the Collection is 0?
> I tried this in the Repository but it doesn't work:
>
> public function countEmpty(){
> $query = $this->createQuery();
> return $query->matching($query->equals('registrations.count',
> 0))->count();
> }
>
>
> But this doesn't seem to work.
> Do you have an idea how to solve this?
>
> Regards
> David
>
>
> 2014/1/20 David Sporer <david.sporer at gmail.com>
>
> > Hi,
> > I have a Model containing an 1:n relationship:/** * The
> > pushNotificationRegistrations * @var
> > \Doctrine\Common\Collections\Collection<\My\Project\Domain\Model\Registration>
> > * @ORM\OneToMany(mappedBy="User") */ protected $registrations;
> > Is it possible to find all Objects where the count of the Collection is
> > 0?I tried this in the Repository but it doesn't work:public function
> > countEmpty(){ $query = $this->createQuery(); return
> > $query->matching($query->equals('registrations.count', 0))->count(); }
> > But this doesn't seem to work.
> > Do you have an idea how to solve this?
> > RegardsDavid
> > _______________________________________________
> > Flow mailing list
> > Flow at lists.typo3.org
> > http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
> >
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
More information about the Flow
mailing list