1

How do you use lazy loading correctly in Yii? I have two models, Company and Settings. The relationship is defined at Company side with:

'settings' => array(self::HAS_ONE, 'Company', 'settingsId'),

and at Settings side with:

'company' => array(self::BELONGS_TO, 'Company', 'settingsId'),

Now, why does this not work in the Company model:

$settings = $this->settings;
echo $settings->someSetting;

The error is

Property "Company.someSetting" is not defined.

1 Answer 1

5

Shouldn't be that Company has one Settings?

'settings' => array(self::HAS_ONE, 'Settings', 'settingsId'),
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.