A good place I use requestaction is for subtotal of shopping cart.
This way I can place the subtotal of the shopping cart on as many views
as I want just by calling the requestaction.  I could have just as
easily made it a method of the model, but then I would have to set
variable for use in the view.

Another good use is for a side menu.  This way you don't have to call
the data in each of the methods you want the menu to appear in to pass
that data to the renderElement.  Instead with the array('return') it
already returns it properly formatted by a simple call in whatever
views you want the side menu in.

Other than these two examples, I do model->methods and set the data for
use in the view.  In your models if you use $this->query() to run any
custom queries you need and format the query like CakePHP does it will
return to a CakePHP array for easy use.

Here is an example of where you would want code in the model and not
controller.  Say you have a configs table that stores parameters and
values.  You could have a controller method that gets the param and
value passed to it.  You then use $this->Config->saveField() to save
the parameter's value.  Instead you should just place code in the model
so it can be called directly.  $this->Config->saveparam and in that
method it would run $this->saveField as well.  The only difference is
now I can call this directly instead of thru the requestAction.

So, maybe what you are looking for is to make calls directly place your
method in the model.  And remember that you can use all the model
available functions you just don't have to prefix them with the
modelname anymore.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to