Might be a newbie question as I'm trying to see what all these "PHP frameworks" are at my free time.
For starters I want to add multiple tags to multiple photos. I have a tags model and mot model (the photos). Snip of mot model:
var $hasAndBelongsToMany = array(
'Tag' =>
array(
'className' => 'Tag',
'joinTable' => 'mots_tags',
'foreignKey' => 'mot_id',
'associationForeignKey' => 'tag_id',
'unique' => false
)
);
In my tags controller in add() I have:
$this->Tag->save($this->data);
When print_r'ing $this->data I see:
Array
( [Mot] => Array ( [id] => 2 )
[Tag] => Array
(
[title] => 21e21e
)
)
Tag get inserted into Tags table, but nothing gets inserted into mottags(theres underscore between mot and tag but it italics when i write it here instead of becoming an underscore) table. My mots_tags db schema: (sqlite)
create table mots_tags (id INTEGER PRIMARY KEY, mot_id INTEGER, tag_id INTEGER)
Any clues why Cake writes only to Tags table and not to associacions table? I don't get any SQL errors. Is there a way to see if it tries to write to associations table at all?