Tuesday, June 29, 2010

Re: Accessing one model from another (unrelated) model

..but the question was a model in a model, not in a controller.

Ah, that's my bad. Sorry.

On Jun 29, 9:40 am, Erik Starck <erik.sta...@gmail.com> wrote:
> ...but the question was a model in a  model, not in a controller.
>
> I'm using this in my model class:
>
>   $Category = ClassRegistry::init("Category");
>   $category = $Category->findById($underThisCategoryId);
>
> Don't know if there's a better way. loadModel would be nicer I suppose.
>
> BR Erik
>
> On Tue, Jun 29, 2010 at 4:32 PM, Anthony <anthony.c.fra...@gmail.com> wrote:
> > You could make use of the $uses variable.
>
> > Say you need to access the unrelated table Bar from controller Foo,
> > you would add a uses variable for something like:
>
> > $uses = array('Foo', 'Bar');
>
> > On Jun 28, 5:36 pm, WhyNotSmile <sharongilmor...@gmail.com> 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 sitehttp://cakeqs.organd 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 athttp://groups.google.com/group/cake-php?hl=en

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: