开发者

CakePHP i18n, translate behavior, unknown column error when using find() with conditions

I am trying to get the translate behaviour working, i deleted the translated comlumns from the original table and now I am getting er开发者_运维知识库rors when performing the following query:

$menu = $this->Menu->find('first', array('conditions' => array('Menu.title' => 'main-nav')));

My Menu model:

<?php
class Menu extends AppModel {
    var $name = 'Menu';

    var $actsAs = array(
        'Translate' => array(
            'title', 'link_title', 'path'
        ),
        'Tree'
    );

    /*var $belongsTo = array('Content'); disabled for now.. */
}
?>

Here is the SQL/Error generated:

Warning (512): SQL Error: 1054: Unknown column 'Menu.title' in 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 525]

Query: SELECT `Menu`.*, `I18n__title`.`content`, `I18n__link_title`.`content`, `I18n__path`.`content` FROM `ags_menus` AS `Menu` LEFT JOIN `ags_i18n` AS `I18n__title` ON (`Menu`.`id` = `I18n__title`.`foreign_key` AND `I18n__title`.`model` = 'Menu' AND `I18n__title`.`field` = 'title') LEFT JOIN `ags_i18n` AS `I18n__link_title` ON (`Menu`.`id` = `I18n__link_title`.`foreign_key` AND `I18n__link_title`.`model` = 'Menu' AND `I18n__link_title`.`field` = 'link_title') LEFT JOIN `ags_i18n` AS `I18n__path` ON (`Menu`.`id` = `I18n__path`.`foreign_key` AND `I18n__path`.`model` = 'Menu' AND `I18n__path`.`field` = 'path') WHERE `Menu`.`title` = 'main-nav' AND `I18n__title`.`locale` = 'en_gb' AND `I18n__link_title`.`locale` = 'en_gb' AND `I18n__path`.`locale` = 'en_gb' LIMIT 1 

Obviously Im getting the error because the column no longer exists in the Menu model/table, but I assumed the translate behavior automagically took care of this?


I managed to find a solution:

'conditions' => array('I18n__title.content' => 'main-nav')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜