has and belongs to many - CakePHP HABTM question -
There may be a newbie question because I'm trying to see all these "PHP frameworks" on my free time Are there. / P>
For starters, I want to add multiple tags to multiple tags. I have a tag model and mot model (photo). Entity ('classname' = & gt; 'Tag', 'joinTable' = & gt; 'mott_tags', 'foreign key' = & gt; 'mot_id', 'associationforeignkey' = & gt; 'tag_id', 'unique' = & Gt; wrong));
I have () in my Tag Controller in the ad:
$ this-> Tag- & gt; Save ($ this-> Data);
When I see this - $ data-
array
([Mot] => array ( [Title] => 21e21e)
)
[tag] => Tag> tag tags, but nothing is mixed (mutes and underscores between tags) but when I write it instead of being an underscore, the table My mots_tags db schema: (sqlite) to create table mots_tags (id INTEGER primary key, mot_id INTEGER, tag_id INTEGER)
No clue why the cake Only writes tag to table and not for associations table? I do not get any SQL errors, is there a way to see if he tries to write on the composition table?
Try
$ this-> Tag- & gt; Save all ($ - this-> data);
Edit:
OK, you definitely need saveAll ()
In addition, the array of connected HABT models should be in a definite, curious format. If I remember correctly, then it should look like this:
array ('tag' => array ('title' = & gt; ...), / primary model ' Motel '= & gt; array (// connect hbtm model' motel '=> array ($ id, $ id, $ id, ...));
Comments
Post a Comment