cake-php@googlegroups.com
[Top] [All Lists]

Re: Association not by primary key

Subject: Re: Association not by primary key
From: cricket
Date: Wed, 30 Jun 2010 14:30:11 -0400
On Wed, Jun 30, 2010 at 10:15 AM, DragonFlyEye <dragonflyeye74@xxxxxxxxx> wrote:
> I'm trying to make an association between two models that do not use
> the primary key as the association. I'm not sure why I'm getting the
> results that I am from this:
> class SubgroupPage extends AppModel {
>        var $name               = 'SubgroupPage';
>        var $useTable   = 'menu_subgroup_pages';
>        var $primaryKey = 'subgroup';
>        var $hasOne     = array('PageSettings' => array('foreignKey' =>
> 'pageid',
>                                                                'conditions' 
> => array('PageSettings.pageid' =>
> 'SubgroupPage.pageid')));
>
Does this work?

var $hasOne = array(
        'PageSettings' => array(
                'foreignKey' => false,
                'conditions' => array(
                        'PageSettings.pageid' => 'SubgroupPage.pageid'
                )
        )
);

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 cake-php@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
cake-php+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

<Prev in Thread] Current Thread [Next in Thread>