Prado\Caching\TDbCache::createDbConnection PHP Method

createDbConnection() protected method

Creates the DB connection.
protected createDbConnection ( ) : TDbConnection
return Prado\Data\TDbConnection the created DB connection
    protected function createDbConnection()
    {
        if ($this->_connID !== '') {
            $config = $this->getApplication()->getModule($this->_connID);
            if ($config instanceof TDataSourceConfig) {
                return $config->getDbConnection();
            } else {
                throw new TConfigurationException('dbcache_connectionid_invalid', $this->_connID);
            }
        } else {
            $db = new TDbConnection();
            if ($this->_connectionString !== '') {
                $db->setConnectionString($this->_connectionString);
                if ($this->_username !== '') {
                    $db->setUsername($this->_username);
                }
                if ($this->_password !== '') {
                    $db->setPassword($this->_password);
                }
            } else {
                // default to SQLite3 database
                $dbFile = $this->getApplication()->getRuntimePath() . '/sqlite3.cache';
                $db->setConnectionString('sqlite:' . $dbFile);
            }
            return $db;
        }
    }