I have a table as follows which stores categories in multiple Level.
product_categories (id, name, pid, created, modified)
pid = parentID which is a reference to the same table's ID. it is 0
when its a parent Category.
I am not sure how i can configure this using hasMany and belongsTo relation in CakePHP.
Any pointers on how i can get this to work?
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' => ''
)
);