Created
October 19, 2013 23:04
-
-
Save tenebrousedge/7062643 to your computer and use it in GitHub Desktop.
Example of a Hierarchical Model Relation in CakePHP
This is what you usually need instead of Tree Behavior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Category extends Model { | |
public $name = 'Category'; | |
public $hasMany = array('Children' => array( | |
'className' => 'Category', | |
'foreignKey' => 'parent_id' | |
)); | |
public $belongsTo = array('Parent' => array( | |
'className' => 'Category' | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment