Yii: How to set unique table alias for model

Viewed 2971

I'am working on two models.

  1. Credentials
  2. Messages

Credentials model has a default scope method, where I've added addNotInCondition to filter blocked users. Here is my code

public function defaultScope() {
  $criteria = new CDbCriteria();
  $criteria->addNotInCondition("t.id", BanUser::model()->bannedUsers);
  return $criteria;
}

This works fine. But While accessing credentials model from Messages model, it gives me error. Unknown column 't.id'. (BELONGS_TO relation is defined in messages model)

$message->credential; //this generate error.

What could be solution to this problem. I know this is due table aliases. I'm stuck here. Please help.

2 Answers
Related