doctrine2 - Doctrine ORM Conditional Association -
doctrine2 - Doctrine ORM Conditional Association - i'm building q&a site , questions, answers , comments on same posts table. posttype different. can answers question , comments reply association: /** * @onetomany(targetentity="cms\entity\post", mappedby="parent") */ private $answers; /** * @onetomany(targetentity="cms\entity\post", mappedby="parent") */ private $comments; but think not right way because if fetch question both answers , comments filling answers. have set status relation posttype = 1 how can this? your schema invalid. schould have 2 different objects answers , comments 2 different things, if share mutual interface. you should create 2 entities, answer , comment , create assocations them. same thing create abstract class, abstractcontent , defines required fields , accessor methods. doctrine supports inheritance final database schema same, oo model correct. /** * @mappedsuperclass *...