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 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