1
votes

I use the Propel 2 ORM in my php webapplication and in a certain query I like to order my results by field.

$orderedIdArray = array(20, 10, 15, 30);
MyClassQuery::create()
    ->filterById($orderedIdArray, Criteria::IN)
    //->orderByField("Id", $orderedIdArray) --> method does not exist in Propel
    ->find();

I found a solution online to do this via Propel Criteria for the Peer Class. http://shout.setfive.com/2009/10/13/adding-order-by-field-to-propel-criterias/

However I want to do this with my Query Class. How would you implement the method in the Query Class?

1

1 Answers

1
votes

You can just copy&paste his code of addOrderByField into your MyClassQuery class and normally use it. There's no need to use sfCriteria in Propel 2.