Cheers,
Mike
On Wed, Jan 21, 2009 at 11:37 AM, Christer Edvartsen <cogo@starzinger.net> wrote:
Lets say we have a users table, a groups table and an intersection table called usergroups. I my application I have a Users class to represent the users table (extends Zend_Db_Table) and a User class to represent one user (extends Zend_Db_Table_Row). The same goes for the other tables as well.
Now ... lets say we have a form where we want to edit a user (including adding/removing groups). How would you guys go about implementing the saving of the user object and the group relationships?
I'm thinking of writing a custom save() method in the User class that first calls parent::save() to save the user to the users table, and then implement stuff for saving data to the usergroups intersection table. I would also need to add some attributes to the User class and make sure the group relationshis is loaded when a User object is created. Is this the "regular" way of solving this or does Zend_Db have some kind of magic stuff to handle this?
How do other people solve this?
--
Christer Edvartsen
cogo@starzinger.net
http://cogo.wordpress.com/
--
Celebrate Liberty, Freedom, and Rights at http://www.theconstitutionalist.us.
没有评论:
发表评论