Welcome Guest, Not a member yet? Register   Sign In
IgnitedRecord model functionality: hook, behavior or something else?
#1

[eluser]echadwickb[/eluser]
I'm learning ignited record with a small faq app. The app needs to let the user order the each faq element. In the table I've got an order column. When a user changes or adds an faq, I'd like the model to adjust the order of all the faqs in the table to accomodate re-ordering of the element.

So I'd run an sql statement like this right before the save:

UPDATE faqs SET order = order + 1 WHERE order > $this->order

So should I create a behaviour, hook or do something else? Add_hook looks promising, but the documentation implies the hook function needs to be in the controller. Doesn't seem right to put this functionality in the controller. It really belongs in the model. I'm still researching behaviour.

Thanks to anyone who can give me some direction.


Messages In This Thread
IgnitedRecord model functionality: hook, behavior or something else? - by El Forum - 10-22-2008, 08:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB