That is useful to know -- it is not a complete answer to the larger
question: if you create a new model() and save it in the
ClassRepository, use it in one context, then use it in another (or
with nested methods use it back and forth between two different
contexts) are there any predictable/unwanted side efffects? I do like
limiting object instantiation, but was wondering if I could be going
too far.

Asked another way, which types of objects was the ClassRepository
designed to make global?

On Jul 27, 1:59 am, grigri <[EMAIL PROTECTED]> wrote:
> I'm not sure if it was me doing something wrong, but I found an
> annoying side-effect of this.
> If you want to dynamically bind associations, binding occurs on the
> entire model - which is shared.
> So if you have:
>
> class Company extends AppModel {
>   var $hasOne = array(
>     'Logo' => array('className' => 'Image', 'foreignKey' =>
> 'owner_id', 'conditions' => 'Logo.type=\'logo\' AND Logo.owner_type=
> \'company\''),
>     'Map' => array('className' => 'Image', 'foreignKey' => 'owner_id',
> 'conditions' => 'Map.type=\'map\' AND Map.owner_type=\'company\''),
>   )
>
> }
>
> then inside companies_controller you do:
>
> $this->Company->Logo->bindModel(array('belongsTo'  => array(...)));
>
> This affects both $this->Company->Logo and $this->Company->Map, since
> they are the same model.
>
> Still, this really wasn't thought out and might be down to my bad
> design in the first place - I was only experimenting.
>
> On 26 Jul, 20:09, bingomanatee <[EMAIL PROTECTED]> wrote:
>
> > The opportunity for caching model objects as singletons in the
> > ClasssRepository exists; is there any reason why this should NOT be
> > done? Can this create any conflicts that might sabotage your code?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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