我在我的php webapplication中使用Propel 2 ORM,在某个查询中我喜欢按字段排序我的结果。
$orderedIdArray = array(20, 10, 15, 30);
MyClassQuery::create()
->filterById($orderedIdArray, Criteria::IN)
//->orderByField("Id", $orderedIdArray) --> method does not exist in Propel
->find();
我通过Propel Criteria for Peer Class在线找到了解决方案。 http://shout.setfive.com/2009/10/13/adding-order-by-field-to-propel-criterias/
但是我想用我的Query Class做这个。您将如何在Query Class中实现该方法?
答案 0 :(得分:1)
您只需将addOrderByField
的代码复制并粘贴到MyClassQuery
课程中即可正常使用。在Propel 2中没有必要使用sfCriteria
。