I usually add a hook in to app_model for other models to be loaded
without direct associations. I call this key 'knows':

http://bin.cakephp.org/view/1329599461

>From there, you just define the `knows` key in the model

class Something extends AppModel {
  var $knows = array('SomethingElse');

  function do_whatever() {
    $this->SomethingElse->blah(...);
  }
}

You could quite easily define the `knows` key directly in AppModel to
get it loaded for all models. You'd have to override for the Setting
model itself of course, or you'd get into an infinite loop.

Bear in mind that if you do use the `knows` key in another model
you'll have to explicitly add the `Setting` model to the array because
it doesn't inherit/merge the associations, though I'm sure you could
add that functionality if required.

hth
grigri

On Oct 20, 1:26 am, mbavio <[EMAIL PROTECTED]> wrote:
> bootstrap.php?
>
> On Oct 19, 1:20 pm, Smelly_Eddie <[EMAIL PROTECTED]> wrote:
>
> > Better yet.
>
> > What area should I add code to load Persistent Global variables across
> > all my pages.
>
> > That way i can just load all my settings at first visit, and skip all
> > this trouble.
>
> > __SITE_SETTINGS['BotcheckMinMax'];
> > __SITE_SETTINGS['SiteName'];
> > __SITE_SETTINGS['Tagline'];
> > etc..
>
> > I;m thinking I'll call the model from the *app_controller*, and pass
> > the settings back as an array to set as a global variable.
>
> > On Oct 18, 7:36 pm, Pablo Viojo <[EMAIL PROTECTED]> wrote:
>
> > > Sent from my iPhone
>
> > > On 18-10-2008, at 17:07, Smelly_Eddie <[EMAIL PROTECTED]> wrote:
>
> > > > I am having some trouble with the proper way to go about modeling
> > > > this. I would love suggestions.
>
> > > > I have a simple database with an id, key and value fields.   I made an
> > > > administrative model, controller and views to add and manage the table
> > > > of options.
>
> > > > I have some functions in the model that return values based on the
> > > > criteria, and I can call this from any controller easily.
> > > > $minMax= $this->Setting->getBotcheckMinMax();
>
> > > > I need a clean way to let models access the data within this table.
> > > > And I don't want to use relationships because the records really
> > > > relate specifically to any model, but may be used by any.
>
> > > > I tried importing via;
> > > > App::import('Model'.'Setting')
>
> > > $Setting = new Setting();
> > > $Setting->getMinMax()
>
> > > > Setting::getMinMax()
>
> > > > But it died trying to connect to the table once the settings method
> > > > was called.
>
> > > > It would be nice to build a component that could be access by the
> > > > model.  I just don't want to bulk up every controller that wants to
> > > > use some settings. It would be nicer to keep that in the models.
>
> > > > Regards,
> > > > Eddie
--~--~---------~--~----~------------~-------~--~----~
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=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to