Re: Loading models within the controller action

2009-01-13 Thread Jon Bennett
Hi _k10_, > To add more to Brians method, it would be a good practise to set the > model instance to a variable (who's name is the name of the Model) if > you plan to use the model more than once. Actually, that's incorrect. By using ClassRegistry, cake checks for both the required file and a

Re: Loading models within the controller action

2009-01-12 Thread Miles J
I found an easier approach, setting the models in the beforeFilter! Heres my example. /** * Load action specific models * @return void */ function beforeFilter() { switch ($this->params['action']) { case 'games':

Re: Loading models within the controller action

2009-01-12 Thread brian
Just to clarify, this is something I saw on Teknoid's site (and, I think the idea was attributed to Gwoo or Nate). Basically, if there are lots of models needed for just one action (an Admin's index page, to show some site stats, in my case), it's more efficient to use ClassRegistry. Or, so I unde

Re: Loading models within the controller action

2009-01-12 Thread _k10_
To add more to Brians method, it would be a good practise to set the model instance to a variable (who's name is the name of the Model) if you plan to use the model more than once. $this->Member = ClassRegistry::init('Member'); $this->set('new_members', $this->Member->getNewMembers()); _k10_ O

Re: Loading models within the controller action

2009-01-12 Thread Miles J
Basically what brian said. Why load 10 models for an action that only needs 1? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubsc

Re: Loading models within the controller action

2009-01-11 Thread brian
I think the idea is that they're only required for this one action and so putting them all in $uses would entail far too much overhead. On Mon, Jan 12, 2009 at 12:03 AM, Webweave wrote: > > I'm confused by your question, why wouldn't you just add the model to > your $uses: http://book.cakephp.or

Re: Loading models within the controller action

2009-01-11 Thread Webweave
I'm confused by your question, why wouldn't you just add the model to your $uses: http://book.cakephp.org/view/53/components-helpers-and-uses That's the standard way of including a model in your controller. On Jan 10, 10:56 pm, Miles J wrote: > Der... I could call $this->loadModel(). --~--~

Re: Loading models within the controller action

2009-01-10 Thread Miles J
Der... I could call $this->loadModel(). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to ca

Re: Loading models within the controller action

2009-01-10 Thread Miles J
Ive tried doing some logic in beforeFilter() and using App::import, but neither work simply because I use the controller paginate(). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this gro

Re: Loading models within the controller action

2009-01-10 Thread Miles J
Yeah I know of that. But then I have to initialize all the classes also. Was just wondering if there was something that does it on runtime automatically. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" grou

Re: Loading models within the controller action

2009-01-10 Thread Brad V. aka iBspoof
Miles- Try - App::import('Model', "_insert_model_name"); Brad On Jan 10, 6:08 pm, Miles J wrote: > In one of my controllers, I use nearly 10-15 models. The problem is > that I dont need all these models, each model is respective to a > certain action and loading all these models seems like it

Re: Loading models within the controller action

2009-01-10 Thread brian
Based on something I saw on Teknoid's blog, I have this in my Admin index(): $this->set('new_members', ClassRegistry::init('Member')->getNewMembers()); $this->set('new_publications', ClassRegistry::init('Publication')->getNewPublications()); ... Apparently, this is the m