Hello,
I am trying to interrelate models from different data sources (Oracle and Active Directory in this case), and I am getting some funny behavior from recursive associations. Just to clarify: single level association work well.
So, consider model A belongsTo B, and model B hasMany A.
This is an example of the code that I'm trying to execute:
$this->B->find('first', array(
'conditions' => array('id' => '1158'),
'recursive' => -1,
'contain' => array(
'A' => array(
'fields' => array('id', …),
'B' => array(
'fields' => array('id', …),
'A' => array(
'fields' => array(…),
),
),
),
),
));
If the code ran correctly, I'd be getting something that looks like a circular array. However, my code doesn't work as expected and the innermost value ('A') is not present (i.e., my result array looks like [B => …, A => ['field1', …, B => ['field1', 'field2', …]]]), not even as a NULL or empty array. If instead of using containable I set the 'recursive' property OR use containable but leave the fields unspecified, something even stranger happens at the recursion stops one level before that (which is this time an empty array, i.e., I get [B => …, A => ['field1', …, B => []]]).
If I misspell the name of the innermost A on purpose, I get a warning. This is leading me to think that things are somehow, but not quite entirely, working. How could I debug this to find out what the problematic code is? It could be somewhere in the custom datasources or the model definitions.
Thanks,
Ricardo Vieitez | Student Assistant - Network Administration
University of Florida Department of Housing and Residence Education
PO Box 112100 | Gainesville, FL 32611-2100
office 352.392.2171 x10355 | fax 352.392.6819 | RicardoV@housing.ufl.edu
StrengthsQuest Top 5: Analytical, Strategic, Learner, Responsibility, Relator - Find Out More
Please consider the environment before printing this email.
No comments:
Post a Comment