Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Custom orderBy with FIELD
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
conankun  
View profile   Translate to Translated (View Original)
 More options 9 July, 02:24
From: conankun <hendrachrist...@gmail.com>
Date: Wed, 8 Jul 2009 18:24:03 -0700 (PDT)
Local: Thurs 9 July 2009 02:24
Subject: Re: Custom orderBy with FIELD
Hey Phillip,

Ignore my earlier reply, I got it to work with Doctrine_RawSql,
thanks. Here's what I did (for those who face the same thing).

$q = new Doctrine_RawSql();
$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)');

$result = $q->execute()->toArray();

Cheers,
HC

On Jul 9, 10:53 am, "J.Philip" <jphi...@noatak.com> wrote:

> You can do this in Doctrine with a RawSql query.

> -----Original Message-----
> From: doctrine-user@googlegroups.com [mailto:doctrine-user@googlegroups.com]

> On Behalf Of conankun
> Sent: Wednesday, July 08, 2009 4:48 PM
> To: doctrine-user
> Subject: [doctrine-user] Custom orderBy with FIELD

> Hi,

> I would like to know if it's possible to do a custom orderBy with
> Doctrine? In other words, is there any Doctrine equivalent to this
> SQL:

> 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
> 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).

> If it's currently not possible, I hope it will be added in the future,
> thx.

> PS: Let me know if this suppose to be a support ticket or something.

> Cheers,
> HC


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google