|
Is there any way to know if a model exists if you have the name of it in a string? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
Hi Mattalex You can either use the php function class_exists, which checks if the class has been defined. And in case it has not been defined, check for the file in the MODELS directory. Enjoy, John On Apr 19, 7:37 am, mattalexx <[hidden email]> wrote: > Is there any way to know if a model exists if you have the name of it > in a string? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
You could also try ClassRegistry::init() which will attempt to load the class if it isn't already. On Sun, Apr 19, 2009 at 2:35 AM, John Andersen <[hidden email]> wrote: > > Hi Mattalex > > You can either use the php function class_exists, which checks if the > class has been defined. > And in case it has not been defined, check for the file in the MODELS > directory. > > Enjoy, > John > > On Apr 19, 7:37 am, mattalexx <[hidden email]> wrote: >> Is there any way to know if a model exists if you have the name of it >> in a string? > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
> You could also try ClassRegistry::init() which will attempt to load > the class if it isn't already. I believe the recommended way now is (from the controller at least) to use $model = $this->loadModel('ModelName'); Gwoo explains why here http://groups.google.com/group/cake-php/browse_thread/thread/137c57b4eb010317?pli=1 hth Jon > > On Sun, Apr 19, 2009 at 2:35 AM, John Andersen <[hidden email]> wrote: >> >> Hi Mattalex >> >> You can either use the php function class_exists, which checks if the >> class has been defined. >> And in case it has not been defined, check for the file in the MODELS >> directory. >> >> Enjoy, >> John >> >> On Apr 19, 7:37 am, mattalexx <[hidden email]> wrote: >>> Is there any way to know if a model exists if you have the name of it >>> in a string? >> > >> > > > > -- jon bennett w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Powered by Nabble | Edit this page |
