开发者

Cakephp, i18n, SQL Error, Not unique table/alias

开发者 https://www.devze.com 2022-12-23 23:00 出处:网络
I get the following SQL error: SQL Error: 1066: Not unique table/alias: \'I18n__name\' when doing a simple find query.

I get the following SQL error:

SQL Error: 1066: Not unique table/alias: 'I18n__name'

when doing a simple find query.

Any ideas on possible situations that may have caused this?? I'm using a bindModel method to retrieve the data is that related?

This is my code:

$this->Project->bindModel(array(
                                        'hasOne' => array(
          开发者_开发知识库                              'ProjectsCategories',
                                        'FilterCategory' => array(
                                                                'className' => 'Category',
                                                                'foreignKey' => false,
                                                                'conditions' => array('FilterCategory.id = ProjectsCategories.category_id')
                                                                ))));
$prlist = $this->Project->find('all', array(
                                                    'fields' => array('DISTINCT slug','name'),
                                                    'conditions' => array('FilterCategory.slug !='=>'uncategorised')
                                                    ))


You have not used or initialized the required table/model you are using in your controller. Use var $uses = array('your_table_name');


I do not have a direct answer to my problem. However after some research I came to the following conclusion.

I've decided to change my methodology and stop using the translate behavior in cakephp. I've found another behavior called i18n which works much better when dealing with associated models. You can read about it http://www.palivoda.eu/2008/04/i18n-in-cakephp-12-database-content-translation-part-2/#comment-1380 In cakephp book it says :

"Note that only fields of the model you are directly doing find on will be translated. Models attached via associations won't be translated because triggering callbacks on associated models is currently not supported."

I'm not sure if I made the right choice however I have been struggling to get the translate behavior to work in cakephp and this solution at least makes the project I'm working functional.

0

精彩评论

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

关注公众号