Hi! This is my first post on the forum, I can’t speak English very well, so be patient
In AR, how can I access to a select_expr using AR attributes, like I do with a real column field?
An dumb example.
The default scope of User Active Record is:
public function defaultScope()
{
return array(
'select'=>"*, NOW() AS now", //ALL COLUMN AND A select_expr
);
}
I find all records, and want to access to a real column and a select_expr
$users=User::model()->findAll();
foreach ($users as $user) {
print $user->username; //THIS WORK BECAUSE IS A REAL COLUMN
print $user->now; //THIS NOT WORK
}
I thought to use AR method like
public function getNow() {}
but how can I access to
now
field inside there?
Thanks!
P.S.: I now that I could get NOW() value from php, but this is only an example.
My real case is a bit more complex, but this is the essence.