0

Salam(Hi), How I can prevent from loading related model(child) for a (parent) model?

tereško
  • 58,060
  • 25
  • 98
  • 150
Masoud Nazari
  • 476
  • 2
  • 6
  • 17

1 Answers1

0

How do you know they are loaded with parent model? Have you checked the LogRoute? (Uncomment it in the config)

'log' => array(
    'class' => 'CLogRouter',
    'routes' => array(
        ...
        array(
            'class' => 'CWebLogRoute',
            'categories' => 'system.db.*',
            'except' => 'system.db.ar.*',
        ),

Related models are not loaded by default (if you haven't used with('relatedModel') method).

Any related records will be lazy loaded when accessing the relation property the first time. http://www.yiiframework.com/forum/index.php/topic/7430-lazy-loading-of-many-many-relations/page_view_findpost_p_37674

robert.little
  • 410
  • 3
  • 13