Re: Strange association behavior

2009-07-21 Thread Nancy

Sorry, more info to add:

It works fine if I do the query through the Layerrule model, but not
through the Ruleitem model.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Strange association behavior

2009-07-21 Thread Nancy

I just wanted to add, I don't get any error from the query like I
would if I added an unrelated model to the 'contain' array.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Strange association behavior

2009-07-21 Thread Nancy

I must be missing something... maybe fresh eyes can see the problem.
Hopefully!  I have a complex set of table associations that looks like
this:

layers
  id

ruleexceptions
  id

rulevaluetypes
  id

layerrules
  id
  layer1_id
  layer2_id
  ruleexception_id

ruleitems
  id
  layerrule_id
  exception_id

ruleitemvalues
  id
  ruleitem_id
  rulevaluetype_id

Everything works great, except I can't get layerrules and ruleitems to
link up.  The model for layerrules says:

models/layerrule.php:var $hasMany = array('Ruleitem');
models/ruleitem.php: var $belongsTo = array
('Kit','Ruleexception','Layerrule');

Trying to read using any of these models works great except Ruleitem
doesn't link up to Layerrule.  No errors or anything.  Here's one of
my sample queries from Ruleitemvalue model:

function getByRIV($list)
{
$find = array_keys
($list);
$get = $this->find('all', array(
'contain' => array(
'Ruleitem' => array(
'Layerrule',
'Ruleexception',
),
),
'conditions' => array("Ruleitemvalue.id" => $find),
)
);
return $get;
}

Snippet from the data returned:
Array
(
[0] => Array
(
[Ruleitemvalue] => Array
(
[id] => 26
[rulevaluetype_id] => 1
[ruleitem_id] => 14
[kit_id] => 1
[value] => 2
[rule] => def
[valid] =>
)

[Ruleitem] => Array
(
[id] => 14
[layerrule_id] => 24
[ruleexception_id] => 5
[kit_id] => 1
[Ruleexception] => Array
(
[id] => 5
[name] => ntie
[desc] =>
[kit_id] => 1
[nonexception] => 0
)

)

)

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---