Tuesday, May 3, 2011

hasMany mutex?

TableA hasMany TableB. TableB has boolean field called Checkbox
I want checkbox to be a mutex among the TableB records for a given
TableA ID.
The last record that was added or saved with Checkbox = 1 will 'steal'
it from any of the other TableB records for a given TableA ID.

Again, I'm second guessing myself because I'm new to cake, MVC, and
classes in general. I want to make sure I'm not relying on old habits
and do things the hard way instead of taking advantage of what cake
has to offer..

Normally (i.e. if I was just writing 'regular' php) if the saved
record had Checkbox checked, then after saving, I'd just run a second
sql query to uncheck all the other records.

So I understand I can do the same in cake: after I call the save
method, I'd call the execute method and pass in the appropriate SQL to
uncheck any other records.

My question is, is there a way/is it more appropriate to build this
behavior into the model somehow?

Thanks,
Mike


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate