protected function getDb()
    {
        if (isset($this->_db)) {
            return $this->_db;
        } else {
            if (($db = Yii::app()->getComponent($this->connectionID)) === null) {
                throw new CException(sprintf(
                    'Failed to get database connection. Component %s not found.',
                    $this->connectionID
                ));
            }
            return $this->_db = $db;
        }
    }