Using symfony2 but its more just mysql problem...
I think i have good table schema(just the important fields)(code is self explanatory):
users (id) statuses (id) likes (id,user_id,status_id) comments (id,user_id,status_id)
I am making big select.
Was trying this:
$qb=$this->createQueryBuilder('s')
->addSelect('u')
->addSelect('u2')
->addSelect('u3')
->addSelect('l')
->addSelect('c')
->addSelect('s2')
->where('s.user = :user')
->setParameter('user', $user)
->innerJoin('s.user', 'u')
->leftJoin('s.likes', 'l')
->leftJoin('l.user', 'u2')
->leftJoin('s.comments', 'c')
->leftJoin('c.user', 'u3')
->leftJoin('c.status', 's2')
->orderBy('s.time', 'DESC')
->setMaxResults(15);
But the result is 15the same statuses... WRONG.
It worked well when i was selecting just statuses... likes to statuses.. and users(authors of likes and statuses)
Like that:
SELECT * FROM statuses s0_
INNER JOIN users t1_ ON s0_.user_id = t1_.id
LEFT JOIN status_likes s2_ ON s0_.id = s2_.status_id
INNER JOIN users t3_ ON s2_.user_id = t3_.id
WHERE s0_.user_id = 25 ORDER BY s0_.time DESC LIMIT 15
that works very nice but how can i implement the another comments and (users -> authors of comments) select THERE?...