YES!! Fixed it! It seems that renaming everything and going over all the code again worked. I set up the join table and used a 'with' => .. in the model's habtm relations.
Thank you for reviewing my question, and thank you all for CAKE! :) On Apr 16, 10:27 pm, birthdaycake <[email protected]> wrote: > Thank you for your reply, John! > > I have tried what you and the book suggest: > > * I renamed all the models, controllers and folder names with the > Cms* prefix > * I changed the relations accordingly > > This is what happens: > > When I change the HABTM relation to: > > array('CmsMenu' => array('className' => 'CmsMenu' ... > > Cake refuses to load the relations, so I went back to: > > array('Cms.CmsMenu' => array('Cms.className' => 'CmsMenu' ... > > That works for Cake, but the query has syntax errors all over again. > Does this look like a bug? > > It looks like something like this: it uses the period fine as a > reference to a plugin model, but it does not integrate well with the > sanitized query (wrapping the strings around the periods with a "`". > > Any ideas? > > Maybe if I create a model for the join table (cms_menus_links)? > > On Apr 16, 8:06 pm, John Andersen <[email protected]> wrote: > > > > > > > As far as I understand from the CakePHP book on plugins, you are using > > the alternative syntax for naming the association, thus you should not > > use "Cms.Menu" but "Menu" as your association key. > > Seehttp://book.cakephp.org/view/117/Plugin-Models > > > Are your model for the menu named Menu or CmsMenu? > > The CakePHP book do suggest that you add your plugin name to the model > > name, thus Menu becomes CmsMenu, and thus you should be able to avoid > > conflict with other models in the application (in case on is named > > Menu). > > > Hope this helps you on the way, enjoy, > > John > > > On Apr 16, 4:48 pm, birthdaycake <[email protected]> wrote: > > > > Imagine a plugin called Cms, with several models, two of them called > > > Menu and Link. > > > > The Links have a HABTM relationship to the Menus. In order to set that > > > up in the model I used the following relationship in the Link model: > > > > {{{ > > > var $hasAndBelongsToMany = array( > > > 'Cms.Menu' => > > > array( > > > 'className' => 'Cms.Menu', > > > 'joinTable' => 'cms_menus_links', > > > 'foreignKey' => 'link_id', > > > 'associationForeignKey' => 'menu_id', > > > 'unique' => true, > > > 'conditions' => '', > > > 'fields' => '', > > > 'order' => '', > > > 'limit' => '', > > > 'offset' => '', > > > 'finderQuery' => '', > > > 'deleteQuery' => '', > > > 'insertQuery' => '' > > > ) > > > ); > > > > }}} > > > > As you can see, I use the prefix Cms. for the className as well as for > > > the key in the array. This is needed for Cake understands the relation > > > between my models and my plugin Cms from it. > > > > Now look at the query Cake creates after I call a find in my > > > LinkController in the Cms plugin: > > > > {{{ > > > SELECT > > > `cms`.`Menu`.`id`, > > > ... > > > `cmsMenusLink`.`menu_id`, > > > `cmsMenusLink`.`link_id` > > > FROM `cms_menus` AS **`cms`.`Menu`** > > > JOIN `cms_menus_links` AS `cmsMenusLink` > > > ON (`cmsMenusLink`.`link_id` = 4 > > > AND `cmsMenusLink`.`menu_id` = `cms`.`Menu`.`id`) > > > > }}} > > > > The query fails (syntax error) because it wants to join on an alias > > > called `Cms`.`Menu`. How can i fix this? > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers > > > 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 [email protected] > > > To unsubscribe from this group, send email to > > > [email protected] For more options, visit this group > > > athttp://groups.google.com/group/cake-php?hl=en > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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 [email protected] > > To unsubscribe from this group, send email to > > [email protected] For more options, visit this group > > athttp://groups.google.com/group/cake-php?hl=en > > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 [email protected] > To unsubscribe from this group, send email to > [email protected] For more options, visit this group > athttp://groups.google.com/group/cake-php?hl=en 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
