【发布时间】:2017-05-03 08:38:23
【问题描述】:
我正在尝试了解如何在 ORM find() 方法中的 cakephp3 订单函数中创建自定义订单函数。
假设我有以下模型
User
name
...
custom_data
custom_data
type
每个用户都有一个自定义数据,其中类型是 [20,30,40] 之一。
我需要按以下方式按这种类型订购
if ( type == 20 ) {
// put in first positions
} else {
// put this records after users with custom_data->type != 20
}
我需要在分页器中使用它,所以我需要类似的东西
$this->Users
->find()
->where([ something ] )
->order( 'ASC' => here is my custom function )
有什么建议吗?
【问题讨论】:
标签: cakephp orm query-builder cakephp-3.x