Wednesday, June 30, 2010

Association not by primary key

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')));

Which end up looking like this:

SELECT [PageSettings].[pageid] AS [PageSettings__40], [PageSettings].
[page_name] AS [PageSettings__41], [PageSettings].[default_levelid] AS
[PageSettings__42], [PageSettings].[status] AS [PageSettings__43],
[PageSettings].[page_template] AS [PageSettings__44],
CONVERT(VARCHAR(20), [PageSettings].[mod_date], 20) AS
[PageSettings__45], [PageSettings].[secure] AS [PageSettings__46] FROM
[page_settings] AS [PageSettings] WHERE [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@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: