[FLOW3-general] QueryInterface orderBy OneToMany property
Karsten Dambekalns
karsten at typo3.org
Tue Nov 6 10:46:26 CET 2012
Hi.
On 05.11.12 12:47, Robin Lehrmann wrote:
> Now I want to fetch all customers ordered by products ASC.
Ordered by products? No, that lacks the definition how you would order
the products. By name, weight, EAN, …
> The customer with existing products first:
Ah, so, by number of products the customer "has" (ordered, paid, in the
basket?).
> $query = $this->createQuery();
> return $query->setOrderings(array('products' =>
> \TYPO3\Flow\Persistence\QueryInterface::ORDER_ASCENDING))->execute();
>
> It returns NULL? Maybe I should ordered by the count of products? I dont
> know.
This would order by the content of … yes, by what? The command is not
precise enough. Your case is probably best solved by using DQL and
involves the COUNT() function available there.
Make your repository extend the Doctrine\Repository in Flow, so that you
have the EntityManager available. Then search for "count" on
http://doctrine-orm.readthedocs.org/en/2.0.x/reference/dql-doctrine-query-language.html
and you should be on your way.
Regards,
Karsten
--
Karsten Dambekalns
TYPO3 Core Developer, Neos / Flow Team
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the FLOW3-general
mailing list