2011-03-31 75 views
1

有了:找到第三個層次遞歸

function view($id = null) { 
    if (!$id) { 
     $this->Session->setFlash(__('Invalid Post', true)); 
     $this->redirect(array('action' => 'index')); 
    } 
    $this->set('post', $this->Post->read(null, $id)); 

} 

我能找到相關的用戶,但用戶有檔案。

當我列出相關用戶,我想有個人資料的電子郵件,而不是PROFILE_ID

Post $hasAndBelongsToMany Users $belongsTo Profile. 

表:

用戶

Posts_Users

帖子

配置文件。

答:

function view($id = null) { 
    if (!$id) { 
     $this->Session->setFlash(__('Invalid Post', true)); 
     $this->redirect(array('action' => 'index')); 
    } 
    $this->Post->recursive =2; 
    $this->set('post', $this->Post->read(null, $id)); 

} 

回答