我正在为我的项目使用 CakePHP... 为了加快我的代码速度,我只想获得一些与我的实际对象相关的模型:
$result = $this->Category->find(
'first',
array(
'conditions' => array(
'Category.folder' => $path[0]
),
'contain' => array('Rubric',
'conditions' => array('Rubric.category_id' => 'Category.id'),
'contain' => array('Subrubric',
'conditions' => array('Subrubric.rubric_id' => 'Rubric.id')
)
)
)
);
path[0] 是来自 url 的参数...
找到了类别和量规,但没有找到子量规。还有一些与我的对象相关的条目,但我希望它们出现在我的 rubric 视图中,而不是类别视图中。
模型关系:
类别:
public $hasMany = array(
'Rubric' => array(
'className' => 'Rubric',
'foreignKey' => 'category_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => 'title',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
专栏:
public $hasMany = array(
'Entrieslocation' => array(
'className' => 'Entrieslocation',
'foreignKey' => 'rubric_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Subrubric' => array(
'className' => 'Subrubric',
'foreignKey' => 'rubric_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
在这里,我不想要入口位置...