So I ran into an interesting problem. I’m using scopes to return data that only belongs to a user, base on his account ID.
public function scopes() {
return array(
'user'=>array(
'condition'=>"accountId=".Yii::app()->user->accountId,
),
'active'=>array(
'condition'=>"active=1",
),
);
}
I have 2 different apps accessing the model. One of the apps has no idea about users, logins, etc…its just pulling data. The other app is the front end, which needs to only show the user their own data.
However the problem comes in that the USER scope causes the first app to error, but it isn’t even being used. Is this the way it should work? My guess is the failure is because Yii::app()->user doesn’t exist in the first app, but always exists in the second.
Still, I’m puzzled as to why Yii would even look at the scope if it isn’t being used.
Thoughts?
Thanks,
Matt