do two hasMany relationships to that table, and make a model for it
i've done that way to make a 'Vote' model , where I have a user_id
and a movie_id , and the value for the vote also.
phpnut said something about cake having this in a future release
(adding different fields to a join table)
spark
On 9/3/06, Dolorian <[EMAIL PROTECTED]> wrote:
>
> Have tried many different wayes, but with no success. I can't think out
> how to populate a join table which has more than two fields.
>
> In the index controller I 'm using the following:
>
> $this->set('langs', $this->Lang->findAll());
>
> In the form:
>
> .. input fields for the seasons table ...
> $html->input('Season/Year');
> .....
> ... input fields for the seasons_langs table ....
> <?php foreach ($langs as $lang): ?>
>
> Name:
> <input type="text"
> name="langData[<?= $lang['Lang']['lang_id'] ?>][SeasonLang][info]" />
>
> <?php endforeach; ?>
>
> So, in the controller I get an array:
>
> $this->params['form']['langData'][1][SeasonLang][Info]
> and
> $this->params['form']['langData'][2][SeasonLang][Info]
> (suppose we have two languages)
>
> Then I make a record for the season :
>
> $this->Season->save($countries_data)
>
> and then I build the arrays for the seasons_langs:
>
> $seasons_langs_data['SeasonLang']['season_id'] =
> $this->Season->getLastInsertID();
>
> foreach ($this->params['form']['langData'] as $key => $value) {
>
> $countries_langs_data['SeasonLang']['lang_id'] = $key;
> $countries_langs_data['SeasonLang']['name'] =
> $value['SeasonLang']['info'];
>
> $this->Season->SeasonLang->save($seasons_langs_data);
> }
>
> Then in the seasons_langs table I have only one record. Cakephp saves
> the record for the first language in the first iteration and then just
> updates this record on the second iteration.
>
>
> >
>
--
[web] http://synapsisdi.com.br
[livesets] http://djspark.com.br
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---