#5649: HABTM save() does UPDATE instead of INSERT
---------------------------------------------------+------------------------
    Reporter:  ddaffy                              |          Type:  Bug     
      Status:  new                                 |      Priority:  Medium  
   Milestone:  1.2.x.x                             |     Component:  Model   
     Version:  RC3                                 |      Severity:  Critical
    Keywords:  habtm, primary key, update, insert  |   Php_version:  PHP 5   
Cake_version:  1.2.0.7692 RC3                      |  
---------------------------------------------------+------------------------
 Let's say Tag HABTM User. Executing:
 {{{
 $this->TagsUser->create();
 $this->TagsUser->save(array('tag_id' => $tag_id, 'user_id' => $user_id));
 }}}
 on join table model (TagsUser), UPDATE of `user_id` is done instead of
 INSERT if record with `tag_id`==$tag_id exists
 {{{
 UPDATE `tags_users` SET `tag_id` = 1, `user_id` = 2 WHERE
 `tags_users`.`tag_id` = 1
 }}}
 (`tag_id` is taken for $primaryKey automagicaly, but things stay the same
 if I create TagsUser model, and if I change $primaryKey to `user_id` then
 `tag_id` is updated). In tags_users table, primary key is (tag_id,
 user_id).

 Tested and reproduced on RC3 and latest from SVN (rev 7774). On RC2 it
 works fine.

-- 
Ticket URL: <https://trac.cakephp.org/ticket/5649>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" 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/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

  • [CakePHP : The Rapid Dev... CakePHP : The Rapid Development Framework for PHP

Reply via email to