Yes, that is the way it works. And I had a lot of problems with that as well
You can use a plugin like this to avoid loading all models: https://github.com/lorenzo/lazy_loader Upgrading your application would be the best idea, though On Monday, May 4, 2015 at 11:34:16 PM UTC+2, DigitalDude wrote: > > Hey guys, > > I'm wondering if anyone has a clue on this one, but I need to check if > this is the standard behavior or not in CakePHP 1.3. > > Let's say I want to create a model anywhere in my app. Besides a lot of > other options, I could do this with: > > $Post = ClassRegistry::init('Post'); > > When I trace the call stack of my function, I see that cake invokes EVERY > related model (via belongsTo, hasMany etc.). And it is doing it recursive, > so when I hit a second related model with a back-connection to the first > model, it constructs them another time all the way trough. > > I have an app on Cake 1.3 with about 150 models, which are nearly all > related to each other via model-paths/associations. When I trace the call > stack and check what models get constructed, it will end up in constructing > nearly 600 (!) model-classes (some models are instantiated at least 35 > times). > > > I checked this with Cake 2, and it behaves completely different. Only the > models targeted within finds or accessing data from other models, those > models are instantiated. The only thing I know of for the moment is > removing those relations and use on-the-fly bind/unbind within all actions, > but this would be a hell lot of work to do (and easier to migrate the whole > app to cake2). > > So my question is: > > Is this normal for CakePHP 1.3 to create ALL related models/classes as > well? Did anyone of you had similar problems when the app grew and you had > more than 100 models? I'm really sure I setup all relations correctly and I > already tested a lot if there is any wrong relation that might cause a > recursion loop... > > Maybe it's time for splitting the app into smaller services to avoid those > complex relations and recursions... > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
