php - Symfony: how to sort One2Many/Many2One of an entity? -
i've 3 entities: product
, productpicture
, picture
.
i'd sort pictures it's position , tried this, code below.
result: it's not sorting joined pictures position. it's sorting products pictures' position.
i'm confused. far can see, followed docs, weird result. cache cleared.
any ideas? in advance!
entity: product
// ... class product { /** * @orm\column(name="id", type="integer") * @orm\id * @orm\generatedvalue */ protected $id; /** * @orm\onetomany(targetentity="productpicture", mappedby="product") * @orm\orderby({"position" = "desc"}) // <------ !!! */ protected $pictures; // ... }
entity: productpicture
// ... class productpicture { /** * @orm\column(name="id", type="integer") * @orm\id * @orm\generatedvalue */ protected $id; /** * @orm\column(type="integer") */ protected $position; /** * @orm\manytoone(targetentity="product", inversedby="pictures") * @orm\joincolumn(name="product_id", referencedcolumnname="id") */ protected $product; /** * @orm\manytoone(targetentity="picture") * @orm\joincolumn(name="picture_id", referencedcolumnname="id") */ protected $picture; // ... }
entity: picture
// ... class picture { /** * @orm\column(name="id", type="integer") * @orm\id * @orm\generatedvalue */ protected $id; /** * @orm\column(name="path", type="string") */ protected $path; // ... }
the docs right:
<?php /** @entity **/ class user { // ... /** * @manytomany(targetentity="group") * @orderby({"name" = "asc"}) **/ private $groups; }
in case findall()
-method of repository
overwritten led mess. make sure, customized queries not in conflict doctrine defaults, if you've same issue. :-)
Comments
Post a Comment