-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CActiveRecord allow attributes as getters and setters #1708
Comments
example model: class MyModel extends ActiveRecord
private $_prop;
public function setProp($val)
{
$this->_prop=$val;
}
public function getProp()
{
if(isset($this->_prop)
return $this->_prop;
// calculate my property
// ....
return $this->_prop;
}
// ... and i try to select like: |
👍 for this issue |
Changed the issue title. This is related to #1245 |
In my humble opinion, this is also linked to this issue: |
It is better to resolve #627 (CActiveRecord not respecting attributeNames() overrides). Do not forget there should be an option to add virtual property, which is NOT an attribute. |
Closing this in favor of #627. |
The problem still present. So #627 didnt help, |
@cebe can you please explain how to use I've got simple use case: private $_email;
public function getEmail()
{
return $this->_email;
}
public function setEmail($email)
{
if (empty($email)) {
$this->_email = null;
$this->status_email = Subscriber::STATUS_EMAIL_EMPTY;
} else {
$this->_email = $email;
if ($this->status_email == Subscriber::STATUS_EMAIL_EMPTY) {
$this->status_email = Subscriber::STATUS_EMAIL_ACTIVE;
}
}
} Is there anything I can do to make it working? Right now when I read record from the database the It looks like the only option for me now is to use Thank you! |
Hi! I try to select query rows with my custom user property(with getter and setter) defined in model. But i can't, because populateRecord doesn't know anything about setters.
The text was updated successfully, but these errors were encountered: