| |
doctrine-user |
Hey Phillip,
Ignore my earlier reply, I got it to work with Doctrine_RawSql,
$q = new Doctrine_RawSql();
$result = $q->execute()->toArray();
Cheers,
On Jul 9, 10:53 am, "J.Philip" <jphi...@noatak.com> wrote:
> -----Original Message-----
> On Behalf Of conankun
> Hi,
> I would like to know if it's possible to do a custom orderBy with
> SELECT * FROM `table` ORDER BY FIELD(id,2,5,3,6,4,1);
> I know I can do a normal Doctrine_Query and traverse the results array
> If it's currently not possible, I hope it will be added in the future,
> PS: Let me know if this suppose to be a support ticket or something.
> Cheers,
thanks. Here's what I did (for those who face the same thing).
$q->select('{t.*}')
->from('table_name_in_db t')
->addComponent('t', 'Table')
->where('foreign_key_id = ?', $foreign)
->orderBy('FIELD(id,2,5,3,6,4,1)');
HC
> From: doctrine-user@googlegroups.com [mailto:doctrine-user@googlegroups.com]
> Sent: Wednesday, July 08, 2009 4:48 PM
> To: doctrine-user
> Subject: [doctrine-user] Custom orderBy with FIELD
> Doctrine? In other words, is there any Doctrine equivalent to this
> SQL:
> and do manual sorting (which is my current alternative), however it
> would be good if I can just grab the custom sorted data straight from
> the SQL (since MySQL also supports this).
> thx.
> HC