Tuesday, December 29, 2009

Re: 1 controller 2 models =)

usually you dont need to change the $uses array!

they should be linked inside the model anyway - with hasMany and
belongsTo relations
this way you should refer to them inside the controller:

$this->Image->foo()
$this->Image->Article->bar()


On 29 Dez., 14:40, Renato de Freitas Freire <renat...@gmail.com>
wrote:
> in your controller, you can set as many models as you want to use.
>
> like:
>
> var $uses = arraya('Image','Article');
>
> to save data in each model, you can just access it like:
> $this->Image->save($your-data-var);
> $this->Article->save($your-other-data-var);
>
> if there is a way to make your article model save the image on image model,
> i dont know... but that way work..
>
> --
> Renato de Freitas Freire
> ren...@morfer.org
>
> On Tue, Dec 29, 2009 at 2:41 AM, Wils <anjo.virt...@gmail.com> wrote:
> > Hi Guys,
>
> > How's going?
>
> > so, I trying to figure out the following scenario:
>
> > 2 models:
> >  - articles
> >  - images
>
> > on my images table i have a column id_article.
>
> > 1 view:
> >  - article + the field to upload 1 image.
>
> > Problem:
> > HOw to store the image using article_model and pass the data to
> > images_model?
>
> > tks
> > Wils
>
> > 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<cake-php%2Bunsubscribe@googlegroups.com>For more options, visit this group at
> >http://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: