I have three tables A, B, C. A and B have a one-to-many relationship. B and C have another one -to-many relationship. In another word, each A can have multiple Bs, while each B can have multiple Cs.
Now I want to do a query for a given record of A, to get all the related Bs which have related Cs. In another word, for a given a, which is a record in table A, I want to get all of the related Bs from table B, providing that each of the Bs also has more than zero related Cs in table C.
How to write the statement in PHP doctrine? I have some code which doesn't work:
Doctrine_Query::create()->from('B b')->leftJoin('C c') ->andWhere('b.A_id = ?', a.id)->andWhere('c.b_id = b.id');