[FLOW3-general] QueryInterface orderBy OneToMany property

David Sporer david.sporer at gmail.com
Mon Nov 5 15:49:42 CET 2012


Hey Robin,

yep I think you need to order by count of products.
Try products.count instead of products.

Regards
David

-----Ursprüngliche Nachricht-----
Von: flow3-general-bounces at lists.typo3.org
[mailto:flow3-general-bounces at lists.typo3.org] Im Auftrag von Robin Lehrmann
Gesendet: Montag, 5. November 2012 12:48
An: General discussion about FLOW3
Betreff: [FLOW3-general] QueryInterface orderBy OneToMany property

Hello together.

I create a Query and set an ordering with an OneToMany property.
My two Models:

Customer:
protected $name;

@OEM\OneToMany(mappedBy="customer", cascade={"remove"}) protected $products;

Product:
protected $name;

@ORM\ManyToOne(inversedBy="products")
protected $customer;

Now I want to fetch all customers ordered by products ASC.
The customer with existing products first:

Customer A has 3 Products
Customer B has 1 Products
Customer C has 0 Products

my repository method:
$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.

Please Help me!
Cheers, Robin.
_______________________________________________
FLOW3-general mailing list
FLOW3-general at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general



More information about the FLOW3-general mailing list