We are also losing faith in your ability to spell...

Sorry, but even if you'd spelt it right,  it's a terrible choice for a
subject title.  The rest of us read the subject to see whether we can
either help or learn from the other replies. All your title does is
make everyone feel negative.

On Apr 5, 9:47 pm, keen <[EMAIL PROTECTED]> wrote:
> My problem: Users -> habtm -> Teams. Users get invited to teams, when
> they accept, they disapear from invitation list and become members.
> Obvious design would be habtm table with additional fields like
> 'membership status' = 'invited'/'member', but i remembered that
> additional habtm fields and cake doesn't mix if i try to update one
> invitation of some user to particular team all invitations of that
> team will be deleted and then reinserted loosing additional fields. So
> i ended up with two tables - for members and for invited.
> After a lot of headache trying to come up with the elegant code for
> deletion one habtm relationship and adding another one for the same
> model, i finally i thought i got it with deleteAll, but no...
>
> Firstly i couldn't get ->save method to work if i had following model
>
> team
> <..>
> var $hasAndBelongsToMany = array(
>                         'Userteam' => array('className' => 'User',
>                                                                 'joinTable' 
> => 'teamusers',
>                                                                 'foreignKey' 
> => 'team_id',
>                                                                 
> 'associationForeignKey' => 'user_id',
>                                                                 'unique' => 
> true,
>                                                                 'conditions' 
> => '',
>                                                                 'fields' => 
> '',
>                                                                 'order' => '',
>                                                                 'limit' => '',
>                                                                 'offset' => 
> '',
>                                                                 'finderQuery' 
> => '',
>                                                                 'deleteQuery' 
> => '',
>                                                                 'insertQuery' 
> => ''
>                         ),
>                         'UserteamInvites' => array('className' => 'User',
>                                                                 'joinTable' 
> => 'teamusersinvites',
>                                                                 'foreignKey' 
> => 'team_id',
>                                                                 
> 'associationForeignKey' => 'user_id',
>                                                                 'unique' => 
> true,
>                                                                 'conditions' 
> => '',
>                                                                 'fields' => 
> '',
>                                                                 'order' => '',
>                                                                 'limit' => '',
>                                                                 'offset' => 
> '',
>                                                                 'finderQuery' 
> => '',
>                                                                 'deleteQuery' 
> => '',
>                                                                 'insertQuery' 
> => ''
>                         )
>         );
>
> and before save i had part of an array that looked like this
>
> $data['Team']['id'] = 15
> <..>
> $data['UserteamInvites']['UserteamInvites'][0] = 1
> <..>
> $data['Userteam']['Userteam'][0] = 2
> $data['Userteam']['Userteam'][1] = 13
>
> After save my db would look like
> Userteam table:
> Team User
> 15 1
>
> UserteamInvites table:
> Team User
> 15 2
> 15 13
> 15 1 <-- ?
> 15 13 <- ?
>
> I solved this by unset($data['Userteam']) first, saving $data, then
> restoring $data['Userteam'] and unset($data['UserteamInvites']) then
> saving for the second time...
>
> That looked ugly, so i thought i'd create a separate model just for
> habtm table and use deletAll and create, save. But i was suprised
> again as i did deleteAll(array('team_id'=>'15','user_id'=>'13')); ALL
> the records with team_id got deleted... I came to square one and had
> to admit that cake didn't have a solution for this common scenario, i
> was left with -query-.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to