views:

243

answers:

2

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')
                                                    ))
A: 

Ion do you have any SQL output you could post indicating how cake is trying to build the query? also do you have any behaviours attached to you models?

Leo
A: 

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.

ion