以下是我的情景:
这是我的分页代码:
$this->paginate['Subfirm'] = array(
'contain' => array(
'Firm' => array(
'Firmtype',
'conditions' => $firmtype,
'Job' => array(
'Person'
),
'Attachment' => array(
'conditions' => array(
'Attachment.attachmentgroup_id' => 7
),
),
),
'Subfirmdetail' => array(
'Subfirmdetailtype' => array(
'Subfirmdetailoption',
),
),
'Substrategy'
),
'order' => array(
$order,
),
'conditions' => array(
'Subfirmdetail.value = 40',
),
);
return $this->paginate('Subfirm');
假设我想要Subfirmdetail.value为40,否则不要显示公司。这是我试图基于(甚至更深......)过滤的场景类型。被困了一段时间,所以任何帮助将不胜感激!
答案 0 :(得分:2)
您需要使用INNER联接。
$joins = array(
array(
'table' => 'subfirmdetail',
'alias' => 'Subfirmdetail',
'type' => 'inner',
'conditions' => array( 'Subfirmdetail.value = 40', 'Subfirmdetail.subfirm_id = Subfirm.id' )
),
array(
'table' => 'subfirmdetailtype',
'alias' => 'Subfirmdetailtype',
'type' => 'inner',
'conditions' => array( 'Subfirmdetailtype.subfirmdetail_id = Subfirmdetail.id' )
),
array(
'table' => 'subfirmdetailoption',
'alias' => 'Subfirmdetailoption',
'type' => 'inner',
'conditions' => array( 'Subfirmdetailoption.subfirmdetailtype_id = Subfirmdetailtype.id' )
)
);
$this->paginate['Subfirm'] = array(
'fields' => array(
'Subfirmdetail.*', 'Subfirmdetailtype.*', 'Subfirmdetailoption.*'
),
'joins' => $joins,
'contain' => array(
'Firm' => array(
'Firmtype',
'conditions' => $firmtype,
'Job' => array(
'Person'
),
'Attachment' => array(
'conditions' => array(
'Attachment.attachmentgroup_id' => 7
),
),
),
'Substrategy'
),
'order' => array(
$order
)
);
return $this->paginate('Subfirm');
答案 1 :(得分:0)
您可能希望对此使用可点击行为:https://github.com/Terr/linkable