S B
S B

Reputation: 8384

Yii: Adding an alias variable to CActiveRecord instance

My User class is derived from CActiveRecord. It has a field email mapped to a database and there is an extension which needs the variable to be named mailaddress.

How can I add a member variable named mailaddress under User class, so that it returns the value stored in email?

Upvotes: 0

Views: 332

Answers (1)

Jon
Jon

Reputation: 437336

Add a read-only component property to your User class:

public function getMailAddress() {
    return $this->email;
}

Upvotes: 1

Related Questions