Cakephp Containable可以显示更深层的数据或联接表

Cakephp Containable可以显示更深层的数据或联接表,cakephp,join,pagination,cakephp-2.0,containable,Cakephp,Join,Pagination,Cakephp 2.0,Containable,我有3个表:项目、项目提醒用户、项目类型 The relations is as follow: Project => belong to => ProjectType hasMany => ProjectReminderUser ProjectReminderUser => belong to => Project ProjectType => hasMany => Project 我获得的所有数据都是基于此系统分配

我有3个表:项目、项目提醒用户、项目类型

The relations is as follow:
Project => belong to => ProjectType
           hasMany   => ProjectReminderUser

ProjectReminderUser => belong to => Project

ProjectType => hasMany   => Project
我获得的所有数据都是基于此系统分配给谁(ProjectMemberUser)的

结果是这样的

array(
    'ProjectReminderUser' => array(
        'id' => '96',
        'user_id' => '1',
        'project_id' => '46'
    ),
    'Project' => array(
        'id' => '46',
        'project_type_id' => '9',
        'contact_id' => null,
        'company_id' => null,
        'subject' => 'Test Modified Field',
        'description' => 'Test Modified Field',
        'ProjectFile' => array(
            (int) 0 => array(
                'id' => '19',
                'project_id' => '46',
                'user_id' => '6',
                'file_path' => '46_bhbinary_xmm_1728.jpg',
                'notes' => null,
                'created' => '2013-11-26 18:37:49'
            ),
        ),
        'ProjectComment' => array(
        )
    ),
    'User' => array(
        'password' => '*****',
        'id' => '1',
        'group_id' => '1',
        'email' => 'xxx@xxxxx.com',
        'first_name' => 'xxxx',
        'deleted' => false,
        'displayName' => 'xxxxx'
    )
)
$this->Paginator->sort('ProjectType.name', 'Type');
结果中有Project.Project\u type\u id的数据,但我想了解更多细节。所以我可以把它显示为名字而不是数字。也许可以改为使用ProjectType.name。 如何实现这一点,以便在视图中对其进行排序?像这样的

array(
    'ProjectReminderUser' => array(
        'id' => '96',
        'user_id' => '1',
        'project_id' => '46'
    ),
    'Project' => array(
        'id' => '46',
        'project_type_id' => '9',
        'contact_id' => null,
        'company_id' => null,
        'subject' => 'Test Modified Field',
        'description' => 'Test Modified Field',
        'ProjectFile' => array(
            (int) 0 => array(
                'id' => '19',
                'project_id' => '46',
                'user_id' => '6',
                'file_path' => '46_bhbinary_xmm_1728.jpg',
                'notes' => null,
                'created' => '2013-11-26 18:37:49'
            ),
        ),
        'ProjectComment' => array(
        )
    ),
    'User' => array(
        'password' => '*****',
        'id' => '1',
        'group_id' => '1',
        'email' => 'xxx@xxxxx.com',
        'first_name' => 'xxxx',
        'deleted' => false,
        'displayName' => 'xxxxx'
    )
)
$this->Paginator->sort('ProjectType.name', 'Type');

问题是Paginator不能很好地处理深层模型关联。我认为,如果您不使用Cake的方法进行模型关联,而是手动进行连接,那么您可能可以根据需要进行排序。请参阅下面的讨论

更糟糕的是,您可能还必须重写模型的paginate函数,以处理排序方式。

如何

'contain' => array(
                        'Project' => array(
                            'ProjectComment',
                            'ProjectFile',
                            'ProjectType',
                        ),
                        'User'
                    ),
看起来您没有包含“ProjectType”