【发布时间】:2014-10-15 12:24:19
【问题描述】:
虚拟属性可以代表模型吗?我读过这个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'..
我怎样才能继续它的工作?
【问题讨论】:
标签: yii model virtual-attribute