Well you kinda hijacked Renesistemic's thread... but anyway...

1. I'm pretty sure it takes both and means the same thing.
2. Town would need to actsAs Containable... however I add it to my
AppModel so all of my models have the ability.
3. I would have thought so... but there is an easy way to test!

Cheers,
Adam

On Nov 6, 7:09 pm, "Liebermann, Anja Carolin"
<[EMAIL PROTECTED]> wrote:
> Thank you for the hint!
>
> Containable seems to offer amazing possibilities.  I read the cookbook 
> article on it (http://manual.cakephp.org/view/474/Containable) and 3 
> Questions arose:
>
> 1st:
> I wonder about the syntax to get more than one associated model back.
>
> Lets say I call $this->Hotel->find
>
> Hotel belongs to a town and a country and has many images.
>
> In my call I would be interested in the information on town and country and 
> want to ignore the images.
> I sths possible and what would be the correct syntax?
> $this->Hotel->contain('Town','Country');
> Or
> $this->Hotel->contain(array('Town','Country'));
>
> Looking 
> athttp://api.cakephp.org/1.2/class_containable_behavior.html#41f468f246...
> The first option seems to be better.
>
> 2nd:
> Let's say I am in my hotels_controller.php and from there I want to call 
> information on my Town
> E.g.
> $this->Hotel->Town->findByFoo($foo);
> Now I would like to limit the associated models for town. Can this be done 
> from the hotel_cotroller? If yes, how?
> E.g.
> $this->Hotel->Town->contain('Quarters');
> Where would I have to place the
>
> var $actsAs = array('Containable');
>
> In the hotels_controller.php or in the town_controller.php or both?
>
> 3rd.
> Does contain work only with find or also with findBy?
>
> Thank you for all enlightening comments!
>
> Anja
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected] [mailto:[EMAIL PROTECTED] Im Auftrag von Adam 
> Royle
> Gesendet: Donnerstag, 6. November 2008 07:46
> An: CakePHP
> Betreff: Re: Undesired Recursion in Models
>
> Well the recursion is just symbolic. Cake will only create one instance for 
> each of your models and uses references to that one model throughout your 
> app. You can test this out in your controller.
>
> var $uses = array('Site', 'Post');
>
> function test(){
>         if ($this->Site->Post === $this->Post) {
>                 echo 'adam is right!';
>         } else {
>                 echo 'ok adam lied!';
>         }
>         exit;
>
> }
>
> So really the only issue is that you're requesting more data from your models 
> than you actually want. This is where the Containable behavior comes in. It 
> will automatically prune your recursive associations based on what data you 
> want.
>
> But you can read up on that elsewhere. Hope this helps and best of luck with 
> your project!
>
> Cheers,
> Adam
>
> On Nov 6, 2:10 pm, Renesistemic <[EMAIL PROTECTED]> wrote:
>
> > Hi. I've scoured the web to my best extent without wasting away days
> > of time on this, and I'm stuck... I'm running a CakePHP site with RC3,
> > and am having some serious memory overhead issues. As I came into this
> > project picking up the pieces of another programmer, I've recently
> > decided it'd be best to restructure the architecture of the model
> > relationships, as that seemed to be the major problem.
>
> > I have what could be best understood as three models. We'll call them
> > Site, Post, and Datavalues. The problem comes into play when I look at
> > the variable $this in the app_controller function. When I dump that
> > variable using the debug() method, I'm presented with about 3000 lines
> > of data, among which some of the code references indices of an array
> > inside a Model storing a sub-array of a Parent model, this of course
> > being prefixed by a line indicating * RECURSIVE.
>
> > I have a separate CakePHP site running with different models, and on
> > that site everything checks out with my model architecture. I realize
> > that I've left this problem contextually generalized, but there's no
> > sense in writing a novel if no one has any thoughts or interest in
> > this issue. Additionally, I thought that this problem might be known
> > well enough already that, upon reading this article, someone might be
> > able to offer a suggestion.
>
> > As such, is anyone familiar with issues involving recursive model
> > architecture in CakePHP? Thanks for any feedback you may have to
> > offer.
>
> > The Site model is set up with the assignment:
> > var $hasMany = array(
> >                         'Post' =>
> >                                 array('className' => 'Post',
> >                                                 'foreignKey' =>
> > 'site_id',
> >                                 )
> >         );
>
> > The Post model is set up with the assignment:
> > var $hasMany = array(
> >       'Datavalue' =>
> >         array('className' => 'Datavalue',
> >               'foreignKey' => 'post_id',
> >              )
> >       );
>
> > And lastly, the Datavalue model is set up as follows:
> > var $belongsTo = array(
> >                   'Post' =>
> >         array('className' => 'Post',
> >                                                   'foreignKey' =>
> > 'post_id',
> >                                 )
> >         );
--~--~---------~--~----~------------~-------~--~----~
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