nainy
nainy

Reputation: 540

Yii: add prefix/postfix to model class naming

Is there any way I can get Yii to work with models that have a prefix or postfix in their class name?

For example, I have a table user, which corresponds to the model User. Now, I want this model to have a prefix, say, EmulatedUser. Is there any way to achieve that without renaming my table?

Upvotes: 0

Views: 185

Answers (1)

Joni
Joni

Reputation: 111329

The table and class name don't have to be the same. You can override the tableName in your model:

<?php
class EmulatedUser extends CActiveRecord {
   public function tableName() {
        return 'user';
   }
}

Upvotes: 2

Related Questions