php - HABTM SaveAssociated is performing a SELECT instead UPDATE in CakePHP -


when performin following saveall:

$this->loadmodel('foo');      $my_data = array(            'foo'=> array('id' => 1),         'bar' => array()         );     $my_values = array(1, 2, 3);     foreach ($my_values $key => $value) {                 array_push($my_data['bar'], array(                     'id' => $value,                     )                 );             }     $this->foo->saveall($data, array('deep' => true)); 

the [foo_has_bar] table wasn't updated.

when checking queries i've found select:

begin;   update my_db.foo set id = 1 my_db.foo.id = 1; select foo_has_bar.bar_id my_db.foo_has_bar foo_has_bar foo_has_bar.foo_id = 1; commit; 

my model following:

foo model:

var $hasandbelongstomany = array(         'bar' => array(             'classname' => 'bar',             'jointable' => 'foo_has_bar',             'foreignkey' => 'foo_id',             'associationforeignkey' => 'bar_id',             'conditions' => '',             'fields' => '',             'order' => '',             'limit' => '',             'offset' => '',             'finderquery' => '',             'deletequery' => '',             'insertquery' => ''         )     ); 

the my_data generated array folowing: {"foo":{"id":1},"bar":[{"id":1},{"id":"2"},{"id":"3"}]

if supress multisave, , generate array this: {"foo":{"id":1},"bar":{"id":"3"} every thing works fine.

why when pushing multiple bar doesn't save?


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -