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' => ''
)
);