我有一个这样定义的自引用表:-
public $hasMany = array(
'ChildCategory' => array(
'className' => 'Category',
'foreignKey' => 'parent_category_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
public $belongsTo = array(
'ParentCategory' => array(
'className' => 'Category',
'foreignKey' => 'parent_category_id',
'conditions' => array('ParentCategory.parent_category_id' => '0'),
'fields' => '',
'order' => ''
)
);
我们只有一级父子,所以一棵树有点难。我正在尝试对查找进行编码以获取仅用于添加编辑功能的父母列表。
$parentCategories = $this->Category->ParentCategory->find('list');
但是sql不包含我的条件???
选择ParentCategory
。id
, ParentCategory
. name
从bidup
。categories
1 ParentCategory
= 1
是否有理由不包括该条件?