Re: Accessing models
That is the wrong way. You should use $Model = ClassRegistry::init('ModelName); On Nov 30, 11:07 pm, brassman79 wrote: > so I figured out that I can access a model to save and retrieve data > from components by saying $myvar = new ModelName(); > > etc. > > I have another model that keeps giving me this error. > > Fatal error: Class 'StatisticsUser' not found in ... > > the problem that I think I'm having is that this is the "join" table > for users and statistics. > > how do I write to this table properly thru cake? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Accessing models
Hello, > I have another model that keeps giving me this error. > > Fatal error: Class 'StatisticsUser' not found in ... > > the problem that I think I'm having is that this is the "join" table > for users and statistics. > > how do I write to this table properly thru cake? So do you have that class created in app/models? Regards, Piotr Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Accessing models from outside their main controller
Which version of cake are you using ? 2008/4/21, Smelly_Eddie <[EMAIL PROTECTED]>: > > > I tried that, I get; > Fatal error: Class 'App' not found in /srv/www/htdocs/cake/app/ > controllers/components/tickets.php on line 3 > > What does that mean? > > > > On Apr 20, 9:01 am, Sliv <[EMAIL PROTECTED]> wrote: > > Components do not load models automatically, you have to manually load > > them with: > > > > component: > > > > function startup(&controller) { > > App::import('Model', 'ModelName'); > > $MyModel = new ModelName;} > > > I just started working with CakePHP today, and I was wondering how to > > > access a model from within a component. > > > -- Avant d'être grand, il faut comprendre le petit... --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Accessing models from outside their main controller
I tried that, I get; Fatal error: Class 'App' not found in /srv/www/htdocs/cake/app/ controllers/components/tickets.php on line 3 What does that mean? On Apr 20, 9:01 am, Sliv <[EMAIL PROTECTED]> wrote: > Components do not load models automatically, you have to manually load > them with: > > component: > > function startup(&controller) { > App::import('Model', 'ModelName'); > $MyModel = new ModelName;} > > I just started working with CakePHP today, and I was wondering how to > > access a model from within a component. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Accessing models from outside their main controller
There's no such var in a component, though, so declaring it wouldn't have any effect. On Sun, Apr 20, 2008 at 10:43 PM, Daddy Cool <[EMAIL PROTECTED]> wrote: > > Wouldn't it be also possible to use the controllers method ? > > ==> var $uses = array('model1','model2'); > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Accessing models from outside their main controller
Wouldn't it be also possible to use the controllers method ? ==> var $uses = array('model1','model2'); --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Accessing models from outside their main controller
Components do not load models automatically, you have to manually load them with: component: function startup(&controller) { App::import('Model', 'ModelName'); $MyModel = new ModelName; } > I just started working with CakePHP today, and I was wondering how to > access a model from within a component. > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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=en -~--~~~~--~~--~--~---
Re: accessing models
thankyou to all your responses. I wasn't asking in order to solve a particlar problem but just wanted to know how it all fits together. I think its probably wise not to do this anyway, and work from the controller when working with more than one model, but handy to know. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: accessing models
There are a few ways: If It's a model associated with This Model (like hasMany, HABTM, etc) , you would trye this in your controller: $this->Model1->Model2->findAll() If you want to do other operations, you might use var $uses = array('Model1','Model2','Model3'); $this->Model1->findAll() $this->Model2->findAll() $this->Model3->findAll() Or if want to access an Action of a Model, you may call it , use RequesAction. It executes and return a value or the rendered page: (Chapter 7 in the manual) requestAction($url, $extra = array()) $url is like '/galleries/view/3' an useful example from the manual: $this->set('users', $this->requestAction('/users/getUserList')); and, to render the same action, just do an 'echo' to the var $userTable in your view: $this->set('userTable', $this->requestAction('/users/getUserList', array('return'))); spark On 5/30/06, monty <[EMAIL PROTECTED]> wrote: > > hi there, > this is probably already been posted , but cant' find. > How do you access a Model from within another Model. > > Thankyou. > > > > > -- [web] http://synapsisdi.com.br [livesets] http://djspark.com.br --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: accessing models
Use the $uses var like this:$uses = array('Model1','Model2','Model3');You then have access to all these models like this:$this->Model1$this->Model2 (...)FFighter. On 5/30/06, nate <[EMAIL PROTECTED]> wrote: If the second model is associated with the first, it's a simple matterof $this->Second, where $this is the primary model, and Second is thename of the associated model. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: accessing models
If the second model is associated with the first, it's a simple matter of $this->Second, where $this is the primary model, and Second is the name of the associated model. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: accessing models
What are you trying to do exactly? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---