I have a situation where I have a user model & a department model.
MODEL - User.php
var $hasAndBelongsToMany = array(
'Department' => array('className' => 'Department',
'joinTable' =>
'departments_users',
'foreignKey' => 'user_id',
'associationForeignKey' =>
'department_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
MODEL - department.php
var $hasAndBelongsToMany = array(
'User' => array('className' => 'User',
'joinTable' =>
'departments_users',
'foreignKey' => 'department_id',
'associationForeignKey' =>
'user_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
So...my problem is this:
I baked my application's controllers, views, and models via the
console and they are still the defaults.
I currently have 2 users & 2 departments in the database.
Whenever I associate a user with a single department (doesn't matter
which one) everything works fine.
Whenever I associate a user with both departments I get the following
error:
Warning (512): SQL Error: 1062: Duplicate entry '2' for key 1 [CORE/
cake/libs/model/datasources/dbo_source.php, line 521]
Query: INSERT INTO `departments_users` (`user_id`,`department_id`)
VALUES (2,'1'), (2,'2')
Any help would be greatly appreciated. This project was created
exclusively with the 1.2 RC3 so it wasn't an upgrade or anything like
that from RC2 or before.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---