如何在我的列表中放置NULLS来设置默认的DESC排序?我的代码的一部分负责排序:
$dataProvider->sort->defaultOrder = ['created_at' => SORT_DESC];
$dataProvider->sort->attributes['created_at'] = [
'asc' => [Production::tableName().'.created_at' => SORT_ASC],
'desc' => [Production::tableName().'.created_at' => SORT_DESC]
];
此致
答案 0 :(得分:1)
试试这个:
$dataProvider->sort->attributes['created_at'] = [
'asc' => [new Expression(Production::tableName().'.created_at ASC NULLS FIRST')],
'desc' => [new Expression(Production::tableName().'.created_at DESC NULLS LAST')]
];
$dataProvider->sort->defaultOrder = ['created_at' => SORT_DESC];