Skip to content

Instantly share code, notes, and snippets.

@tenebrousedge
Created October 19, 2013 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenebrousedge/7062643 to your computer and use it in GitHub Desktop.
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
<?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