OK, assuming your EnglishWord model has something like:

   // Link to jobs
    var $hasAndBelongsToMany = array(
        'ChineseWord' =>
        array(
                'className'             => 'ChineseWord',
                'joinTable'             =>
'chinese_words_english_words',
                'foreignKey'            => 'english_word_id',
                'associationForeignKey' => 'chinese_word_id',
                'conditions'            => '',
                'order'                 => '',
                'limit'                 => '',
                'unique'                => true,
                'finderQuery'           => '',
                'deleteQuery'           => '',
                'insertQuery'           => ''
        )
   );

How deeply this data is returned is a function of the recursive
setting (if you set recursive to 0, you won't get the Chinese words).

I have an action where I do something similar, and I directly query
the HABTM related data by doing the equivalent of $this->EnglishWord-
>ChineseWord->find('all' ...

You can also try pulling back all of the data by setting recursive to
2.

On Nov 13, 9:28 am, analogue40 <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a problem with HABTM I hope someone cam help! :)
>
> I have 3 tables:
>
> chinese_words
> english_words
> Chinese_words_english_words (this is the join table)
>
> I want to be able to grab a word from the 'english_words' table, and
> also have the 'chinese_words' available too.
>
> From what I can tell, if I did this:
>
> $this->set('enWords', $this->EnWord->find());
>
> Then in my view I should have an array like this:
>
> Array
> (
>     [0] => Array
>         (
>             [EnglishWord] => Array
>                 (
>                     [id] => 83
>                     [field1] => value1
>
>                 )
>
>             [ChineseWord] => Array
>                 (
>                     [id] => 1
>                     [field1] => value1
>                 )
>         )
> )
>
> Although, the query above doesn't pull up any of the chinese words.
>
> To cut this post short so someone might actually read all of it.... ;)
>
> Can someone point me in the direction of how I am supposed to properly
> query a HABTM database?
>
> Thanks in advance!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to