Returns the connection string for the supplied database name

@param string $storeName
@param string|null $podName
@throws \Tripod\Exceptions\ConfigException
@return string
177087
public function getConnStr($storeName, $podName = null)
    {
        if (array_key_exists($storeName,$this->dbConfig))
        {
            if(!$podName)
            {
                return $this->getConnStrForDataSource($this->dbConfig[$storeName]['data_source']);
            }
            $pods = $this->getPods($storeName);
            if(array_key_exists($podName, $pods))
            {
                return $this->getConnStrForDataSource($pods[$podName]['data_source']);
            }
            throw new \Tripod\Exceptions\ConfigException("Collection $podName does not exist for database $storeName");
        }
        else
        {
            throw new \Tripod\Exceptions\ConfigException("Database $storeName does not exist in configuration");
        }
    }
131703
public function getAttributesRawData($storeId, array $entityIds, $tableName, array $attributeIds)
    {
        $select = $this->connection->select();

        // The field modelizing the link between entity table and attribute values table. Either row_id or entity_id.
        $linkField = $this->getEntityMetaData($this->getEntityTypeId())->getLinkField();

        // The legacy entity_id field.
        $entityIdField = $this->getEntityMetaData($this->getEntityTypeId())->getIdentifierField();

        $joinStoreValuesConditionClauses = [
            "t_default.$linkField = t_store.$linkField",
            't_default.attribute_id = t_store.attribute_id',
            't_store.store_id= ?',
        ];

        $joinStoreValuesCondition = $this->connection->quoteInto(
            implode(' AND ', $joinStoreValuesConditionClauses),
            $storeId
        );

        $select->from(['entity' => $this->getEntityMetaData($this->getEntityTypeId())->getEntityTable()], [$entityIdField])
            ->joinInner(
                ['t_default' => $tableName],
                new \Zend_Db_Expr("entity.{$linkField} = t_default.{$linkField}"),
                ['attribute_id']
            )
            ->joinLeft(['t_store' => $tableName], $joinStoreValuesCondition, [])
            ->where('t_default.store_id=?', 0)
            ->where('t_default.attribute_id IN (?)', $attributeIds)
            ->where("entity.{$entityIdField} IN (?)", $entityIds)
            ->columns(['value' => new \Zend_Db_Expr('COALESCE(t_store.value, t_default.value)')]);

        return $this->connection->fetchAll($select);
    }
1008690
function connStr(conn) {
  var conf = mergeDefaults(conn);
  var connString = conf.driver + '://' + conf.username + (conf.password ? ':' + conf.password : '') + '@' + conf.host
    + (conf.port ? ':' + conf.port : '') + '/' + conf.database;
  return connString;
}
34140
public function setDatabaseName($databaseName = "")
    {
        if (empty($databaseName)) {
            throw new GdgCommonsInvalidArgumentException("Database name must not be null or empty");
        }
        
        if (!is_string($databaseName)) {
            throw new GdgCommonsInvalidArgumentException("Database name must be string");
        }
        
        $this->_databaseName = $databaseName;
    }
1251985
public function getTypesInViewSpecifications($storeName, $pod=null)
    {
        return array_unique($this->getSpecificationTypes($this->getViewSpecifications($storeName), $pod));
    }
279157
public function asConnection(Model $entity, ?string $database): ?string
    {
        $repository = $this->app->make('config');
        $tenants = $this->getConfig('connection');

        if (! \is_null($tenants)) {
            $database = $tenants['name'];
        }

        if (\substr($database, -5) !== '_{id}' && $this->getConfig('shared', true) === false) {
            $database .= '_{id}';
        }

        $connection = $this->bindWithKey($entity, $database);
        $name = "database.connections.{$connection}";

        if (! \is_null($tenants) && \is_null($repository->get($name))) {
            $config = $this->app->call($tenants['resolver'], [
                'entity' => $entity,
                'template' => $tenants['template'],
                'connection' => $connection,
                'migrator' => $this,
            ]);

            $repository->set($name, $config);
        }

        return $connection;
    }
15618
public function isPodWithinStore($storeName,$pod)
    {
        return (array_key_exists($storeName,$this->podConnections)) ? array_key_exists($pod,$this->podConnections[$storeName]) : false;
    }
1183810
private static function getConnectionConfiguration($name)
    {
        $databaseConfig = Configuration::get('database.connections');
        if (isset($databaseConfig[$name])) {
            $databaseConfig = $databaseConfig[$name];
        } else {
            $databaseConfig = null;
        }

        if ($databaseConfig === null) {
            throw new ConfigurationException("Database configuration for connection '" . $name . "' doesn't exists!");
        }

        if (! isset($databaseConfig['driver'])) {
            throw new ConfigurationException("Database configuration for connection '" . $name . "' is invalid!");
        }

        return $databaseConfig;
    }
575234
protected function getSchema($connectionName = null)
    {
        $connectionName = $connectionName === null ? $this->connectionName : $connectionName;

        /** @var \Doctrine\DBAL\Schema\AbstractSchemaManager $schema */
        $schema = app('db')->connection($connectionName)->getDoctrineSchemaManager();
        // For MySQL
        $schema->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
        // For Sqlite
        $schema->getDatabasePlatform()->registerDoctrineTypeMapping('long', 'integer');
        $schema->getDatabasePlatform()->registerDoctrineTypeMapping('bit', 'boolean');

        return $schema;
    }
682781
public static function getGeoIPDatabaseTypeFromFilename($filename)
    {
        foreach (self::$dbNames as $key => $names) {
            foreach ($names as $name) {
                if ($name === $filename) {
                    return $key;
                }
            }
        }
        return false;
    }
1089865
public static function configureAndGetDSN() :string {

		// alter the configuration
		self::$_config = array(
			'driver'	=> Config::get('database','driver'),
			'database'	=> Config::get('database', 'database'),
			'hostname'	=> Config::get('database', 'hostname'),
			'username'	=> Config::get('database', 'username'),
			'password'	=> Config::get('database', 'password'),
			'before'	=> Config::get('database', 'before'),
			'quote'		=> '',
			'nulls'		=> [
				'query'		=>'',
				'column'	=>'',
				'true'		=>'',
				'false'		=>'',
			]
		);

		// depending on the driver
		switch(self::$_config['driver']) {
			
			case 'sqlite':
				$dsn = self::configureForSQLite();
			break;
			
			case 'mysql':
				$dsn = self::configureForMySQL();
			break;

			case 'postgres':
				$dsn = self::configureForPGSql();
			break;

			case 'odbc':
				$dsn = self::configureForODBC();
			break;

			case 'sqlsrv':
				$dsn = self::configureForSQLServer();
			break;
			
			default:
				// causes exception
				Throw new Exception('Database::connect() : Unknown driver');
			break;
			
		}

		// the dsn we have assembled
		return $dsn;

	}
538204
public function getChannelsByStoreName(string $storeName, ?string $locale)
    {
        $connections = $this->getConnectionMapByStoreName()[$storeName];

        return $this->getChannelsFilteredByLocale($connections, $locale);
    }
1018155
private function getIndex()
    {
        $indexName = $this->readBaseConfigParam('index');

        return $this->indexManager->getIndexByName($indexName, $this->storeId);
    }
1234771
public function doConnect($config)
    {
        $connectionString = 'sqlite:' . $config['database'];
        return $this->container->build(
            '\PDO',
            array($connectionString, null, null, $config['options'])
        );
    }
1137360
protected function getDatabaseName()
    {
        // Check globals
        global $database;

        if (!empty($database)) {
            return $this->getDatabasePrefix() . $database . $this->getDatabaseSuffix();
        }

        global $databaseConfig;

        if (!empty($databaseConfig['database'])) {
            return $databaseConfig['database']; // Note: Already includes prefix
        }

        // Check environment
        $database = Environment::getEnv('SS_DATABASE_NAME');

        if ($database) {
            return $this->getDatabasePrefix() . $database . $this->getDatabaseSuffix();
        }

        // Auto-detect name
        $chooseName = Environment::getEnv('SS_DATABASE_CHOOSE_NAME');

        if ($chooseName) {
            // Find directory to build name from
            $loopCount = (int)$chooseName;
            $databaseDir = $this->basePath;
            for ($i = 0; $i < $loopCount-1; $i++) {
                $databaseDir = dirname($databaseDir);
            }

            // Build name
            $database = str_replace('.', '', basename($databaseDir));
            $prefix = $this->getDatabasePrefix();

            if ($prefix) {
                $prefix = 'SS_';
            } else {
                // If no prefix, hard-code prefix into database global
                $prefix = '';
                $database = 'SS_' . $database;
            }

            return $prefix . $database;
        }

        // no DB name (may be optional for some connectors)
        return null;
    }
759380
function buildDbConfig(appName, config) {
    var dbDriver = fetchFromConfig(appName, config, 'dbDriver') || 'mongo';
    var defaultPort = dbDriver === 'mongo' ? 27017 : 5432;
    return {
        dbName:         fetchFromConfig(appName, config, 'dbName'),
        dbPath:         fetchFromConfig(appName, config, 'dbPath'),
        dbDriver:       dbDriver,
        dbType:         fetchFromConfig(appName, config, 'dbType')        || 'mongo',
        dbUser:         fetchFromConfig(appName, config, 'dbUser')        || 'nodejs',
        dbPassword:     fetchFromConfig(appName, config, 'dbPassword')    || null,
        dbConnections:  parseInt(fetchFromConfig(appName, config, 'dbConnections')) || 20,
        dbConcurrency:  parseInt(fetchFromConfig(appName, config, 'dbConcurrency')) || 5,
        dbConnectionTimeout: parseInt(fetchFromConfig(appName, config, 'dbConnectionTimeout')) || 60000,
        dbPort: fetchFromConfig(appName, config, 'dbPort') || defaultPort,
        knexDebug: fetchFromConfig(appName, config, 'knexDebug') || false
    };
}
287267
protected function getDblibDsn(array $config)
	{
		$arguments = array(
			'host' => $this->buildHostString($config, ':'),
			'dbname' => $config['database']
		);

		$arguments = array_merge(
			$arguments, array_only($config, ['appname', 'charset'])
		);

		return $this->buildConnectString('dblib', $arguments);
	}