Re: Component and models
I've wanted to do the same thing several times, but they keep telling me it's best of you don't access models from components (don't ask me why). One thing they told me in the IRC chat is that most of the time it's best to pass data as a parameter to the component. Any reusable code that needs to access the model could go in the AppController. I've tried to take this approach with most stuff with pretty good success. The only problem with this in my opinion is that your app controller could get pretty bloated pretty fast. I would really rather have a solid answer as to why accessing a model from a componant is a bad idea... The ACL does it. On May 22, 2:55 am, laeffe <[EMAIL PROTECTED]> wrote: > Hi, I know this has been discussed before, but I just want it to be > clarified. > > From within a component I like to access a Model, what would be the > "correct" approach? > > App::import("Model", "Modelname"); > $modelname =& new Modelname(); > > maybe? --~--~-~--~~~---~--~~ 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: Component and models
While you wait for a more authoritive reply, I'll chip in to say that that's what I've done where I needed to. But I think it depends on the model's association with the controller that loads the component. On Thu, May 22, 2008 at 3:55 AM, laeffe <[EMAIL PROTECTED]> wrote: > > Hi, I know this has been discussed before, but I just want it to be > clarified. > > From within a component I like to access a Model, what would be the > "correct" approach? > > App::import("Model", "Modelname"); > $modelname =& new Modelname(); > > maybe? > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Component and models
Hi, I know this has been discussed before, but I just want it to be clarified. >From within a component I like to access a Model, what would be the "correct" approach? App::import("Model", "Modelname"); $modelname =& new Modelname(); maybe? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---