Can I create an instance of every model everywhere in my application or there is limits to do so. For example can I use below codes everywhere in my app ?
$issue = Issue::model()->findByPk($id);
OR
$issue = new Issue;
Can I create an instance of every model everywhere in my application or there is limits to do so. For example can I use below codes everywhere in my app ?
$issue = Issue::model()->findByPk($id);
OR
$issue = new Issue;
Yes, those codes will work everywhere in your app because Yii uses a "lazy loading" approach which loads the Issue model when it's needed. Just be careful about keeping your code organized. If you are accessing records outside of the associated class's controller or model (e.g. using the first line above in a controller called ArticleController), you might need to use relations instead.