I am new to cakephp. The documentation at http://book.cakephp.org/3.0/en/orm/associations.html#belongstomany-associations and http://book.cakephp.org/3.0/en/orm/saving-data.html#saving-with-associations seem either too brief or very advanced for a beginner like me.
From what I could understand, I have done the following.
//Table Baskets belongsToMany Apples
//At BasketsTable.php in initialize()
$this->belongsToMany('Apples',[
'joinTable' => 'apples_baskets'
]);
A join table apples_baskets in MySQL:
+---+---------+----------+
|id |apple_id |basket_id |
--------------------------
| | | |
--------------------------
I have made the post request data to appear at the controller as:
Array
(
[id] => 1
[xyz] => blahblah
[apples] => Array
(
[_ids] => Array
(
[0] => 1
)
)
[amount] => 15000
)
Now when I perform save, only the Baskets table gets updated, the join table remains untouched, and no error is thrown.
I know I am surely missing something but cant't figure out. Please help !!!