0

我有两个数据库 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_processingvp_record t左外连接tv_schedule tv_schedule( t. sch_id= tv_schedule. sch_id) WHERE (t.tc_id = 22)

     $dataProviderRecorded = new CActiveDataProvider('Record', array(
        'criteria' => array(
            'with' => array('tv_schedule'),
            'condition' => 't.tc_id = '.$id,
            'together' => true
        ),
        'pagination' => array(
                'pageSize' => 20
        )
    ));

但是在记录模型中,以及在调度模型中配置的方法 CDbGetConnection:

 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.'));
}

日程:

    public function getDbConnection() 
    {
            $db=Yii::app()->getComponent('iptv_new');

            if($db instanceof CDbConnection)
            {
                    return $db;
            }
            else 
                    throw new CDbException(Yii::t('yii','Active Record requires a "iptv_new" CDbConnection application component.'));
    }

这里有什么问题?

4

0 回答 0