Yes, that way it works, but according to the cookbook it should also work using the $uses.
Link: http://book.cakephp.org/view/112/Tasks Example from the book: <?php class SoundTask extends Shell { var $uses = array('Model'); // same as controller var $uses function execute() {} } ?> If I can I'd like to avoid doing the app::import. On 11 nov, 05:35, Mohsin kabir <[email protected]> wrote: > you can add some model by importing those . > At the top you can add > > App::import('Model','ModelName'); > > now in the execute() function > > $object=new Model() > $object->find('all') ; > > now it will work . > > On Nov 11, 3:46 am, Crazy <[email protected]> wrote: > > > I'm using a task in one of my cake shell classes. I want to use some > > models there but $uses doesn't seem to work. > > > There is no 'initialize' method, and even if I add it and call the > > parent, it still doesn't seem to do the trick. > > > Anything I'm missing? > > > This is what I'm doing: > > > class MyTask extends Shell { > > var $uses = array('MyModel'); > > > function execute() { > > var_dump($this->MyModel->find('all')); > > } > > > } > > > gives me an "Fatal error: Call to a member function find() on a non- > > object" -- You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=.
