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
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':
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
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
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
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
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().
--~--~
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
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
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
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
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
12 matches
Mail list logo