Chris,

<?php
class Category extends AppModel {

 var $belongsTo =
array('ParentCategory'=>array('className'=>'Category',
'foreignKey'=>'category_id'));

 var $hasMany = array('ChildCategory'=>array('className'=>'Category',
'foreignKey'=>'category_id'));

}
?>

You can see that the className is staying the same so it will use the
current model. The alias, ParentCategory and ChildCategory take on the
attributes of the Category model and are related to other categories
through the category_id.

If no foreignKey is specified, Cake expects the "<alias>_id" in the
table. So, in this example you would have a parent_category_id and
child_category_id.





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to