cakephp:添加后按ID desc排序索引

cakephp:添加后按ID desc排序索引,php,cakephp,cakephp-3.x,Php,Cakephp,Cakephp 3.x,在我的应用程序中,默认情况下,所有索引视图都按名称ASC排序。 只有在添加新行之后,我才需要按ID desc对数据进行排序,以帮助用户查看索引顶部最后添加的行 在控制器中,添加函数: if ($this->Assets->save($asset)) { $this->Flash->success(__('The asset has been saved.')); //die('new id:' . $asset->id

在我的应用程序中,默认情况下,所有索引视图都按名称ASC排序。 只有在添加新行之后,我才需要按ID desc对数据进行排序,以帮助用户查看索引顶部最后添加的行

在控制器中,添加函数:

if ($this->Assets->save($asset)) {
            $this->Flash->success(__('The asset has been saved.'));
            //die('new id:' . $asset->id);
            return $this->redirect(['action' => 'index']);
        }
此尝试无效:

return $this->redirect(['action' => 'index', 'order' => ['id' => 'DESC']]);

我该怎么办?

是否为视图启用了分页功能

如果是这样,则应选择正确的链接

return $this->redirect([
    'action' => 'index', 
    '?' => [
        'sort' => 'id',
        'direction' => 'desc'
    ]
]);