我想连接YII框架与两个数据库但它抛出CDbConnection失败错误的数据库名称

I have used this tutorial to connect YII with two database

I have added a connection string in the protected/config/main.php which is as follows

'db2'=>array(
            'connectionString' => 'mysql:host=localhost;port=3306;dbname=db_name ',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
            'class' => 'CDbConnection'
    ),

I have created a file under

protected/component/AltActiveRecord.php a class file and the code in this file is

`

abstract class AltActiveRecord extends CActiveRecord
    {
        const BELONGS_TO='CBelongsToRelation';
        const HAS_ONE='CHasOneRelation';
        const HAS_MANY='CHasManyRelation';
        const MANY_MANY='CManyManyRelation';
        const STAT='CStatRelation';     
        public static $db2;

        private static $_models=array();            

        private $_md;                               
        private $_new=false;                        

        private $_attributes=array();               

        private $_related=array();                  

        private $_c;                                

        private $_pk;                               

        public function getDbConnection()
        {
            if(self::$db2!==null)
                return self::$db2;
            else
            {


                self::$db2 = new CDbConnection();
                foreach(Yii::app()->db2 as $key => $value)
                    self::$db2->$key = $value;



                if(self::$db2 instanceof CDbConnection)
                {
                self::$db2->setActive(true);
                return self::$db2;
            }
            else
                throw new CDbException(Yii::t('yii','Active Record requires a "db" CDbConnection application component.'));
            }
            }
            }
`

I have created a model which extends to this class and tried to create the object of this model in controller. but it ends with an error, which says

CDbConnection failed to open the DB connection: SQLSTATE[HY000] [1102] Incorrect database name "db_name"

I am wondering why this is not working. Is it related to php version or yii version