[eluser]timobg[/eluser]
Hi,
I am still a novice in CI and DMZ and am trying to make a self relationship in a model Page with parent field and:
relations: has_one and has_many
Should I use a dedicated table for the relations or not?
Code:
<?php
class Page extends DataMapper{
public $table = 'pages';
public $has_one = array('p'=>array('class'=>'page', 'other_field'=>'children'));
public $has_many = array('children'=>array('class'=>'page', 'other_field'=>'p'));
in the DB table 'pages', there is a 'p_id' field for the parent id
In this case in the controller I am using
$data = $this->Page->where('id', 1)->children->get();
But it returns an empty array
Regards!