views:

24

answers:

1

Two Languages belongs to Lset, Lset HABTM Translator

It is defined as follows: Translator:

 var $hasAndBelongsToMany = array(
     'Lset' => array(
           'className' => 'Lset',
           'joinTable' => 'lsets_translators',
           'foreignKey' => 'translator_id',
           'associationForeignKey' => 'lset_id',
     )
  );

Lset:

var $belongsTo = array(
   'langfrom' => array(
       'className' => 'Language',
       'foreignKey' => 'from_id',
),
   'langto' => array(
       'className' => 'Language',
       'foreignKey' => 'to_id',
    )
);

The thing i am doing is :

 $this->paginate['Translator']['contain'] = array('Lset' =>array('langfrom', 'langto'));
 debug($this->paginate());

In my opinion I should get Translator with Lsets, each of them with associated Language, but i only get an error:

SQL Error: 1054: Unknown column 'Lset.langfrom' in 'field list'

How should I do this ?

A: 

okay, found that. assosciants should be named with capital letter.

Yep - the model name is always Capitalised, camelCased singular. The db name should be lowercase underscored plural. You can deviate from this, but then you have to start telling CakePHP about it.
Leo