the issue does not get solved with removing indexes... it simply
double (and invent) some associations which are not clear on RC3
On 4 Ott, 16:19, nachopitt <nachop...@gmail.com> wrote:
> Glad to hear that, I was about to ask information for primary keys or
> maybe a unique index including both foreign keys.
>
> On Oct 4, 12:25 am, Keith <kmedli...@gmail.com> wrote:
>
> > Nevermind...lol too late to be coding...
>
> > For some reason the user_id column in the departments_users table had
> > been set as a primarykey. I'm not exactly sure why, but who knows
> > maybe I totally bailed and set a primarykeyflag somewhere along the
> > line.
>
> > Everything is working though.
>
> > On 4 Oct, 01:12, Keith <kmedli...@gmail.com> wrote:
>
> > > 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:Duplicateentry '2' forkey1 [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 cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment