Welcome Guest, Not a member yet? Register   Sign In
DMZ self relationship parent_id
#1

[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!


Messages In This Thread
DMZ self relationship parent_id - by El Forum - 11-19-2010, 03:36 PM
DMZ self relationship parent_id - by El Forum - 11-19-2010, 04:19 PM
DMZ self relationship parent_id - by El Forum - 11-19-2010, 04:38 PM
DMZ self relationship parent_id - by El Forum - 11-20-2010, 12:23 PM
DMZ self relationship parent_id - by El Forum - 11-20-2010, 12:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB