Hello,

I try to get the 20 last record of a table in asc order, it is simply done
with a sql query but when i try to do it with doctrine i got many problems

I first tried to get them in desc order and after reverse the collection in
doctrine, but the only way is to get the key values reverse it (with
array_reverse) and then get each record with a loop on this array. But i
found this solution ugly so i try to it in sql :

$query = $this->createQuery('c')
            ->innerJoin('c.User')
            ->where('c.auction_id = ? AND c.id IN (SELECT c2.id FROM Chat c2
WHERE c2.auction_id = ? ORDER BY c2.created_at DESC LIMIT 0, 20)',
array($auction_id, $auction_id))
            ->orderBy('created_at ASC');

Problem : Doctrine cut my subquery, and remove the limit part, so my
subquery is useless (^^)
I try also to do a reverse directly on Doctrine Collection but that doesn't
work

If you have a better solution than the first one i'm ready to take it ....

Ty,

-- 
Joel WURTZ
Etudiant ingénieur à EISTI PAU
06 23 64 03 55
2 passage des alliées
64000 Pau

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to