[FLOW3-general] ManyToMany Association ("owningSide", "inversedSide")

Regine Rosewich regine.rosewich at hoellenberg.biz
Wed May 16 16:51:53 CEST 2012


Hi Davide,

may be understood your problem wrong, but as far as I can see you only have to remove hotel1 from user 1 by using a remove-Method within the user-controller (user1->removeHotel($hotel1)).

Regine

Am 16.05.2012 um 16:05 schrieb Davide CD:

> 
> Hi!
> I have two classes, User and Hotel which are connected with a ManyToMany relationship. These classes are partially described here (only properties and methods that are involved in the relationship).
> http://pastebin.com/hheDCvdw
> 
> I use Extjs with FLOW3. 
> A Extjs Grid gives the possibility to assign to a hotel many users. Hotel is the Owningside of this relationship. I can add and remove users assigned to a specific hotel with no problems. Everything works fine.
> The (big, for me) problem is the inverse side of the relation, when I try to assign many hotels to a user. I read in Doctrine Documentation that you MUST also update the owning side of the relationship (how ??). That's why I put that "for cycle" in the user's method "setHotels". Now, lets say that user 1 has no hotels assigned to it:
> user1 -> -  no hotels assigned to
> Let's assigned to hotels to the user1, say, hotel1 and hotel2.
>> From ExtJS, I send an array to a FLOW3 REST Controller with the two identities of hotel1 and hotel2.
> user1 -> hotel1, hotel2
> No problem here. Everything works fine. The hotels are correctly assigned to the user.
> Now, I would like to remove hotel1 in order to have only hotel2 assigned to user1:
>> From ExtJS, I send an array with the only the identity of hotel2.
> 
> user1 -> hotel2
> And here is the big problem. I don't know how I can do it. I recieve errors like "DUPLICATE KEY Entry for ...." (. 
> In other words, I don't know how to avoid the duplicate entry. How can I test (should I ??) if an entry still exists in the association table?
> Or this is the wrong approach?
> Thank you very much in advance.
> Davide
> 
> 		 	   		  
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general



More information about the FLOW3-general mailing list