Up vote 0 down vote favorite share g+ share fb share tw.
I have the following association: Site - hasMany - Sitekey Sitekey - belongsTo - Site sites. Id is primary key sitekeys. Site_id is foreign key in site model: var $hasMany = array('Sitekey'); the query: $this->find('all', array('conditions' => array('Sitekey.
Keyword_id' => $key), 'recursive' => 1)); fetching (find 'all') recursively with that association does not work. I have tried explicitly defining the class name, foreign key, etc... As a last ditch effort, I simply tried changing the site model to: var $hasOne = array('Sitekey'); When I do the recursive find 'all' on this, it does the join and returns the data correctly. Any idea what I am doing wrong or techniques I can use to debug/fix the problem?
Thanks! Cakephp recursion model associations link|improve this question asked Sep 8 '11 at 0:39Craig Oley1.
Var $hasMany = array( 'Sitekey' => array( 'className' => 'Site', 'foreignKey' => 'site_id' )); For me, this happens when the Inflector doesn't correctly singularize and pluralize your nouns. I've made it a practice to always check this first. If this does work, then in theory you should look at why it's not recognizing it.
Create another model Bar (or some other word that it knows), and give it the same associations as sitekey, and see if it works in your site. If so, again, it's most likely the inflector on Sitekey.
The $this keyword like you have used it (assuming we are in a controller) would be an instance of the controller, not the model. Therefore, your results would be based on the default model for the controller. Be sure your controller "uses" the model you are trying to query.
$results = $ModelName->find('all', array('conditions' => array('Sitekey. Keyword_id' => $key), 'recursive' => 1)); I'd suggest looking into the containable behavior as well. You get more control than just using recursive.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.