public function getDbConnection() { if (self::$db !== null) { return self::$db; } else { //这里就是我们要修改的 self::$db = Yii::app()->getComponent('db2'); //self::$db=Yii::app()->db2; if (self::$db instanceof CDbConnection) { return self::$db; } else { throw new CDbException(Yii::t('yii', 'Active Record requires a "db2" CDbConnection application component.')); } } }
/** * Returns the static model of the specified AR class. * Please note that you should have this exact method in all your CActiveRecord descendants! * @param string $className active record class name. * @return TblBasePay the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }