How do I do a custom manytomany insert with CakePHP
I have a setup that has a many to many relationship between customer and media which at the moment is accessed in the interface by going into the media and selecting several customers and hitting save.
I need to make a separate screen which will allow you to select one or many customers and for a predetermined set of media add all these into the database.
The table that stores the relationship is customers_media
and stores customer_id
and media_id
, I will have an array of the media_id's
I need to add, so essentially someone will go into the screen and select the customers they want, these customer ids will be granted rights to all of the media in my array.
I am not sure of the best way to achieve this whilst sticking to the design patterns within Cake so any he开发者_JAVA技巧lp would be greatly appreciated.
I ended up having to create some custom SQL and put it into the Model as a function, which I can call from the controller.
精彩评论