oop - Order a "sub level" record - ORM -
let's use orm doctrine , symfony2 framework.
whe have 3 entity (a,b,c) related eache other in fashion:
a --[1-m]-- b b --[m-1]-- c let's c has attribute (table column) tell correct order of c records (for user display purposes).
finally, have object of a type fetched using orm.
what's best approach - if - return c object ordered starting a ? have write custom query and, so, lose orm characteristics?
notice
if don't problem, let's remember that, retrieve c object, have pass through b objects ordered in different way order field onto c object and, of course, "copy" order onto b object isn't solution
select a, b, c mapping:entitya join a.b b join b.c c order b.prop1 asc, c.prop1 asc that's there really. c's belong b ordered, while b's belonging a ordered well.
Comments
Post a Comment