我有两个数据库tv_schedule和vp_record。 在vp_record表中设置关系:
'tv_schedule' => array(self::BELONGS_TO, 'Schedule', 'sch_id'),
当我想要获得相关记录时,它对我很有用:
Record::model()->findByPk(2)->tv_schedule
但是当我使用标准来形成dataProvider时,我有错误:
SQLSTATE [42S02]:找不到基表或视图:1146表'video_processing.tv_schedule'不存在。执行的SQL语句是:SELECT COUNT(DISTINCT t
。id
)FROM video_processing
。vp_record
t
LEFT OUTER JOIN tv_schedule
{{1 ON(tv_schedule
。t
= sch_id
。tv_schedule
)WHERE(t.tc_id = 22)
sch_id
但是在记录模型中,以及在计划表配置方法CDbGetConnection的模型中:
$dataProviderRecorded = new CActiveDataProvider('Record', array(
'criteria' => array(
'with' => array('tv_schedule'),
'condition' => 't.tc_id = '.$id,
'together' => true
),
'pagination' => array(
'pageSize' => 20
)
));
时间表:
public function getDbConnection()
{
$db = Yii::app()->getComponent('video_processing');
if ($db instanceof CDbConnection)
{
return $db;
}
else
throw new CDbException(Yii::t('yii', 'Active Record requires a "video_processing" CDbConnection application component.'));
}
这里有什么问题?