虚拟属性可以代表模型吗?我已经阅读了这个wiki,但没有找到答案。
编辑: 目的是让我的模型对用户更明确。
abstract class BaseDonnee{
protected $info;
public function representingColumn(){
return 'info'; //Please, I'm not sure this is right
}
public function setInfo(){
//I can set the attribute's value
$this->info = Info::model()->find('a condition')->info;
}
public function getInfo(){
return $this->info;
}
}
编辑2: 运行代码时,我会得到一个异常:
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Nom de colonne non valide : 'info'..
我怎样才能继续它的工作?