我正在尝试findAllByAttributes使用相关的模型列作为标准之一,但我一直在CDbException说明the column cannot be found.
这是我的模特关系:
public function relations() {
return array(
'MetaData' => array(self::BELONGS_TO, 'ProjectMeta', 'wbse_or_io'),
);
}
Run Code Online (Sandbox Code Playgroud)
这是我的尝试查询:
$listing = ProjectIndex::model()->with('MetaData')
->findAllByAttributes(array(
'report_date'=>$reportDate,
'MetaData.cost_centre'=>$costCentre
)
);
Run Code Online (Sandbox Code Playgroud)
从我通过Google/StackOverflow /这些论坛阅读,我应该能够引用MetaData关系中的cost_centre列.但我不断收到以下错误:
Table "tbl_project_index" does not have a column named "MetaData.cost_centre"
Run Code Online (Sandbox Code Playgroud)
如何引用相关表格列?
Ale*_*lex 11
看一下这个
$listing = ProjectIndex::model()->with(
'MetaData'=>array(
'condition'=>'cost_centre = :cost_centre',
'params'=>array('cost_centre'=>$costCentre))
)
->findAllByAttributes(array('report_date'=>$reportDate));
Run Code Online (Sandbox Code Playgroud)