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.
See http://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.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

Reply via email to