Do you have the self join set up inside your model? Something like this:

        var $belongsTo = array(
                'ParentPort' => array(
                        'className' => 'Port',
                        'foreignKey' => 'uplink_id'
                )
        );

Then you can include the ParentPort model in your contain array and extract 
data from it...I'm guessing but something like this:

> var $paginate = array(
>                'fields' => array('*'),
>                'recursive' => 2,
>                'limit' => 50,
>                'order' => array('Port.hardware_unit_id' => 'asc'),
>                'contain' => array(
>                        'ParentPort' =>
> array('HardwareUnit',
'Port'
> ),'HardwareUnit','Vlan','PortEmploymentGroup')
>  );



Jeremy Burns
[email protected]

On 26 Mar 2010, at 05:41, sebb86 wrote:

> I use this in my controller:
> [controller code]
> var $paginate = array(
>                'fields' => array('*'),
>                'recursive' => 2,
>                'limit' => 50,
>                'order' => array('Port.hardware_unit_id' => 'asc'),
>                'contain' => array(
>                        'Port' =>
> array('HardwareUnit'),'HardwareUnit','Vlan','PortEmploymentGroup')
>  );
> 
> ....
> 
> function view()
>  {
>    $this->set('ports', $this->paginate('Port'));
>  }
> 
> I try to explain it again:
> The table "ports" (class: Port) contains the field "uplink_id". This
> is a self join from "uplink_id" as foreign-key to the primary key "id"
> from table "ports".
> Let's assume, a port has "id"=2 and the value from his "uplink_id" is
> 4. Then i need the HardwareUnit, which is associated with the port
> with primary key "id" = 4.
> If something is not understandable, simply ask again. My english is
> not very well. :/
> 
> ... and -cricket-, really thanks a lot for your help and patience.
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
> 
> To unsubscribe from this group, send email to 
> cake-php+unsubscribegooglegroups.com or reply to this email with the words 
> "REMOVE ME" as the subject.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to