Monday, June 28, 2010

Re: Accessing one model from another (unrelated) model

I guess there are a few options. If the data is coming from a database, you could use loadModel wherever needed (http://book.cakephp.org/view/992/loadModel).

If it is not coming from a database (it's hard coded) you could use a behaviour from within the models that need the information. If you want to get to it  from controllers only, then substitute behaviour for component, or you could even add the data to your config.php file and extract it using Configure::read.

I *think* the behaviour route would perform better.

Jeremy Burns
Class Outfit

jeremyburns@classoutfit.com
http://www.classoutfit.com

On 28 Jun 2010, at 23:36, WhyNotSmile wrote:

I have a model which is kind of generic - it's a list of column
names.  For some models, I need to get a list of all the column
names.  However, I can't do this as they are not associated, so using
the column model throws an error.

I've a feeling I'm meant to be doing this in some other way - i.e.
should the column names be something other than a model?  And how do I
do that?

Or is there a way to tell Cake that a particular model should be
accessible from all others without having to define an association?

I apologise if this is a very dumb question.

Thanks!
Sharon

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: