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