ok I got it: I had to change the parameter "unique" to false....^^
On 18 Sep., 19:53, Tomfox Wiranata <[email protected]> wrote: > ok i tried this and it works, but not perfectly > > $saved = $this->User->save(array( > 'User' => array( > 'id' => 1, > ), > 'Product' => array( > 'Product' => array(21), > ), > )); > > the data 1, 21 is saved correctly. but if I save another one this > entry is overwrited??? whats wrong with that? > > i also tried this > behaviou:http://bakery.cakephp.org/articles/view/add-delete-habtm-behavior > > SAME problem??? > > On 18 Sep., 16:39, Tomfox Wiranata <[email protected]> wrote: > > > hi everyone, > > > I have two models: User and Product with tables users and products. > > there is a HABTM relation involved. > > > so I coded in the product model: > > > var $hasAndBelongsToMany = array( > > 'User' => > > array('className' => 'User', > > 'joinTable' => 'users_products', > > 'foreignKey' => 'product_id', > > 'associationForeignKey' => 'user_id' > > ) > > ); > > > now i have a function in my products controller, that is supposed to > > save this relation in the m:n table "users_products": > > > function rememberThisProduct() > > { > > $this->data['????????']['user_id']= $this -> Session -> > > read('User.id'); > > $this->data['????????']['product_id'] = $this->Product->id; > > $saved = $this->????????->save($this->data); > > > if($saved){ > > $this->render('message','ajax'); > > } > > > } > > > now i filled the blanks with questions marks because I dont know if I > > need to create a model UserProduct or not, and what model do I have to > > take in the saving process? > > > I appreciate your help. thank you! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "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/cake-php?hl=en
