behaviors/ExtensionBehavior.php
public function getDbConnection()
    {
        if (!Yii::app()->hasComponent($this->connectionID)) {
            throw new CException(sprintf('Connection component "%s" does not exist.', $this->connectionID));
        }
        $db = Yii::app()->getComponent($this->connectionID);
        if (!$db instanceof CDbConnection) {
            throw new CException(sprintf(
                'Connection component "%s" is not an instance of CDbConnection.',
                $this->connectionID
            ));
        }
        return $db;
    }
public function getDbConnection()
    {
        if (!Yii::app()->hasComponent($this->connectionID)) {
            throw new CException(sprintf('Connection component "%s" does not exist.', $this->connectionID));
        }
        $db = Yii::app()->getComponent($this->connectionID);
        if (!$db instanceof CDbConnection) {
            throw new CException(sprintf(
                'Connection component "%s" is not an instance of CDbConnection.',
                $this->connectionID
            ));
        }
        return $db;
    }
public function getDbConnection ( ) { if ( ! Yii :: app ( ) -> hasComponent ( $ this -> connectionID ) ) { throw new CException ( sprintf ( 'Connection component "%s" does not exist.' , $ this -> connectionID ) ) ; } $ db = Yii :: app ( ) -> getComponent ( $ this -> connectionID ) ; if ( ! $ db instanceof CDbConnection ) { throw new CException ( sprintf ( 'Connection component "%s" is not an instance of CDbConnection.' , $ this -> connectionID ) ) ; } return $ db ; }
Returns the database connection for this component.
@return \CDbConnection the connection component.
@throws \CException if the component does not exist or is not an instance of CDbConnection.
Returns the database connection for this component .