开发者

Chained contain and paginate in Cakephp

开发者 https://www.devze.com 2023-01-05 21:28 出处:网络
Two Languages belongs to Lset, Lset HABTM Translator It is defined as follows: Translator: var $hasAndBelongsToMany = array(

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开发者_JAVA技巧 only get an error:

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

How should I do this ?


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

0

精彩评论

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