Re: how to access other models from non parent controller
Well usually in controller you work only with default model for the controller binded by conventions and its related models, but in some situation you would like to create a dummy controller which is not using any model, or attach a non-related models for using in the controller. There is where a $uses variable comes handy. d. On 14. Júl, 03:18 h., ビシャルfrom Nepal <[EMAIL PROTECTED]> wrote: > Thank You very much for your help. It really worked for me. Anyways I > was thinking why was cakephp using this $uses when other similar > frameworks like Rails doesnt impose such syntax. > > On Jul 13, 3:18 am, duRqoo <[EMAIL PROTECTED]> wrote: > > > Hey, > > > you need to tell C1 to use M2 model using the $uses public attribute > > of controller, which is an array of class names of models that a > > certain controller will use. So in this case just add var $uses = > > array('M2'); to your C1 controller. > > > If Models are somehow related to each other you dont need to include > > them using $uses variable, just touch the related model through > > default controller model. Like $this->M1->M2->find(...); > > > Hope that helps. > > d. > > > On 12. Júl, 05:08 h., ビシャルfrom Nepal <[EMAIL PROTECTED]> wrote: > > > > Suppose we have two controllers C1 and C2, Similarly M2 is the > > > corresponding models to controller C2.Controller C1 is not using any > > > models. How should I fetch table rows from M2 remaining in controller > > > C1. --~--~-~--~~~---~--~~ 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: how to access other models from non parent controller
Thank You very much for your help. It really worked for me. Anyways I was thinking why was cakephp using this $uses when other similar frameworks like Rails doesnt impose such syntax. On Jul 13, 3:18 am, duRqoo <[EMAIL PROTECTED]> wrote: > Hey, > > you need to tell C1 to use M2 model using the $uses public attribute > of controller, which is an array of class names of models that a > certain controller will use. So in this case just add var $uses = > array('M2'); to your C1 controller. > > If Models are somehow related to each other you dont need to include > them using $uses variable, just touch the related model through > default controller model. Like $this->M1->M2->find(...); > > Hope that helps. > d. > > On 12. Júl, 05:08 h., ビシャルfrom Nepal <[EMAIL PROTECTED]> wrote: > > > Suppose we have two controllers C1 and C2, Similarly M2 is the > > corresponding models to controller C2.Controller C1 is not using any > > models. How should I fetch table rows from M2 remaining in controller > > C1. --~--~-~--~~~---~--~~ 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: how to access other models from non parent controller
Hey, you need to tell C1 to use M2 model using the $uses public attribute of controller, which is an array of class names of models that a certain controller will use. So in this case just add var $uses = array('M2'); to your C1 controller. If Models are somehow related to each other you dont need to include them using $uses variable, just touch the related model through default controller model. Like $this->M1->M2->find(...); Hope that helps. d. On 12. Júl, 05:08 h., ビシャルfrom Nepal <[EMAIL PROTECTED]> wrote: > Suppose we have two controllers C1 and C2, Similarly M2 is the > corresponding models to controller C2.Controller C1 is not using any > models. How should I fetch table rows from M2 remaining in controller > C1. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---