Propel ORM:按字段排序 [英] Propel ORM: Order By FIELD

查看:57
本文介绍了Propel ORM:按字段排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Propel 1.6 使用自定义order by"进行查询

I'm trying to do a query with a custom "order by" with Propel 1.6

select * from myObject ORDER BY FIELD(id, 3, 11, 7, 1)

这不起作用:

myObjectQuery::create()
    ->orderById($someIds)
    ->find()

我该怎么办?

推荐答案

$ids = array(3, 11, 7, 1);

$cids = implode(',', $ids);

myObjectQuery::create()
    ->addAscendingOrderByColumn("FIELD (tableName.id, {$cids})")
    ->find()

这篇关于Propel ORM:按字段排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆