たとえば、入札テーブルとコンソーシアムテーブルがあり、HABTMの場合は中間テーブルtenders_consortiumsを作成しました。今私の要件のために私はモデルTendersConsortiumを作成しました
class TendersConsortium extends AppModel {
/**
* Use table
* @var mixed False or table name
*/
public $useTable = 'tenders_consortiums';
/**
* Display field
* @var string
*/
public $displayField = 'counsortium_id';
//The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* belongsTo associations
* @var array
*/
public $belongsTo = array(
'Tender' => array(
'className' => 'Tender',
'foreignKey' => 'tender_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Counsortium' => array(
'className' => 'Counsortium',
'foreignKey' => 'counsortium_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
しかし、ページ付けデータをフェッチする $this->paginate('TendersConsortium', $TendersConsortium_cond)
と、
array(
(int) 0 => array(
'TendersConsortium' => array(
'id' => '6',
'tender_id' => '3',
'consortium_id' => '3',
'state' => 'Winner',
'created' => '2012-08-08 12:21:28'
)
),
(int) 1 => array(
'TendersConsortium' => array(
'id' => '7',
'tender_id' => '3',
'consortium_id' => '1',
'state' => 'Winner',
'created' => '2012-08-08 12:21:28'
)
)
)
また、再帰レベル2を設定しましたが、入札およびコンソーシアムテーブルから関連データを取得していません。