Thursday, February 14, 2013

Re: HABTM Update existing models

Hi, you should try to get your data in an array structured as  follows:

[User]
[id] => int
[Book]
[0] => book1id
[1]=> book2id
and save your data with a saveAssociated($array) call. Tell me if it works! 
 
 

Il giorno lunedì 1 settembre 2008 09:03:40 UTC+2, Graham Weldon ha scritto:
Hey all,

I've been digging for a good example for exactly what I am trying to
do.
Most of the samples out there I can find are for HABTM relationships
adding and updating, whilst adding a new model instance.

What I am after is the update process / procedure required to update
the association table only, for a couple of existing models. I have a
User management Section, and a Book management section. A user cannot
add books, and their registration process is separated for
authorisation / verification reasons.

Once logged in, they should be able to associate a book to their user
model, from the list of existing books.

Can someone point me to an example of this kind of HABTM update?

Much appreciated.
Cheers.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: