hi, i have category table categories => {id, name, parent} (parent is 0 or id value) how write this relation in model? how to use that model for view sub categories? thanks
i have table row like this : id name parent 1 a 0 2 b 0 3 c 1 4 d 1 5 e 3 6 f 4 7 g 4 ...
and need to be back like this : array ( array(1, a, 0, array( array(3, c, 1, array( array(5,e,3) ) ), array(4, d, 1, array( array(6,f,4), array(7,g,4) )
) ) ), array(2, b, 0) );
Like tree : (countinue to any deep level) a -> c -> e -> d -> f -> g b
If you want tree's you'd better look at nested sets.
You can define self-relations without problems in ORM, but you can not construct a query that automatically and recusively returns the complete tree regardless of the depth.
hi Harro can you give me sample of self-relation please? how can i use model field array ($_properties = array('field1', 'field2', ...)) as class static variable like public static $fields1; public static $fields2; ... thanks
And I don't understand your second question. Can you explain what exactly you want? The $_properties array is just the list of fieldnames in the object.
thanks. i need to define fieldnames as class variable for direct access by IDE (netbeans) class Model_Sample extends \Orm\Model { public $field1; }
and in controller class Controller_Sample extends \Controller_Dashboa { public function action_index() { $test = Model_Categories::forge(); $test->field1 = \Input::post('value1'); (autocomplete with ide like doctrine2 orm) } } very help for table with many columns; very fast develop;