0
我有一个如下的表,其中存储多个级别的分类。使用单表的多级分类
product_categories (id, name, pid, created, modified)
PID =的parentID这是相同的表的ID的引用。当它是一个父类别时,它是0 。
我不知道如何在CakePHP中使用hasMany和belongsTo关系来配置此功能。
任何关于如何让这个工作的指针?
public $hasMany = array(
'SubCategory' => array(
'className' => 'ProductCategory',
'foreignKey' => 'id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
public $belongsTo = array(
'ProductCategory' => array(
'className' => 'ProductCategory',
'foreignKey' => 'pid',
'conditions' => '',
'fields' => '',
'order' => ''
)
);