Return a textual description of the main database connection options.

@return string
556720
protected function getConnectionDescription() {
        $host = $this->host;
        $port = $this->port     ? ':'.$this->port     : '';
        $db   = $this->database ? '/'.$this->database : '';
        return $host.$port.$db;
    }
680057
public static function getDbo()
	{
		if (!self::$database)
		{
			//get config values

			$host = Config::get()->get('database.host');
			$user = Config::get()->get('database.user');
			$password = Config::get()->get('database.password');
			$database = Config::get()->get('database.name');
			$prefix = Config::get()->get('database.prefix');
			$driver = Config::get()->get('database.driver');
			$debug = Config::get()->get('database.debug');

			//added extra code to prevent error when $driver is incorrect

			$options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix);

			self::$database = DatabaseFactory::getInstance()->getDriver($driver, $options);

			//get the debug configuration setting
			self::$database->setDebug(Config::get()->get('debug'));
		}
		return self::$database;
	}
1181161
protected function getOptions()
    {
        return [
            ['namespace', 'ns', InputOption::VALUE_OPTIONAL, 'Namespace for entity and its closure.'],
            ['entity', 'e', InputOption::VALUE_REQUIRED, 'Entity class name.'],
            ['entity-table', 'et', InputOption::VALUE_OPTIONAL, 'Entity table name.'],
            ['closure', 'c', InputOption::VALUE_OPTIONAL, 'Closure class name'],
            ['closure-table', 'ct', InputOption::VALUE_OPTIONAL, 'Closure table name.'],
            ['models-path', 'mdl', InputOption::VALUE_OPTIONAL, 'Models path.'],
            ['migrations-path', 'mgr', InputOption::VALUE_OPTIONAL, 'Migrations path.'],
            ['use-innodb', 'i', InputOption::VALUE_OPTIONAL, 'Use InnoDB tables.'],
        ];
    }
833830
protected function databaseInfo()
    {
        $pdo = $this->database->getConnection()->getPdo();

        $version = $this->ifExists($pdo->getAttribute(PDO::ATTR_SERVER_VERSION));

        $driver = $this->ifExists($pdo->getAttribute(PDO::ATTR_DRIVER_NAME));
        $driver = $this->ifExists((! empty($this->databases[$driver]) ? $this->databases[$driver] : null));

        $this->results['database'] = compact('driver', 'version');

        return $this;
    }
684969
public function getConnectionUrl(): string
    {
        if (array_key_exists('unix_socket', $this->connection_params)) {
            return sprintf(
                'mysql://%s@localhost/%s?unix_socket=%s&server_version=%s',
                $this->connection_params['user'] ?? get_current_user(),
                $this->connection_params['dbname'] ?? 'test',
                $this->connection_params['unix_socket'],
                $this->connection_params['server_version'] ?? '5.6'
            );
        }

        return sprintf(
            'mysql://%s:%s@%s:%s/%s?server_version=%s',
            $this->connection_params['user'] ?? get_current_user(),
            $this->connection_params['password'] ?? '',
            $this->connection_params['host'] ?? 'localhost',
            $this->connection_params['port'] ?? 3306,
            $this->connection_params['dbname'] ?? 'test',
            $this->connection_params['server_version'] ?? '5.6'
        );
    }
869713
public function getBuildConnections()
    {
        if (null === $this->buildConnections) {
            $connectionNames = $this->get()['generator']['connections'];

            $reverseConnection = $this->getConfigProperty('reverse.connection');
            if (null !== $reverseConnection && !in_array($reverseConnection, $connectionNames)) {
                $connectionNames[] = $reverseConnection;
            }

            foreach ($connectionNames as $name) {
                if ($definition = $this->getConfigProperty('database.connections.' . $name)) {
                    $this->buildConnections[$name] = $definition;
                }
            }
        }

        return $this->buildConnections;
    }
1001023
public function getDsn(): string
  {
    // pgsql:host=<hostname>;port=26257;dbname=bank;sslmode=disable

    # Build the DSN
    $_dsn = $this->getDriver().':' . 
            'host=' . $this->GetHost().';' . 
            'port=' . ($this->GetPort()!=0 ? $this->GetPort() . ':' : '26257' ) .
            'dbname=' . $this->GetSchema().';' .
            'sslmode=' . $this->getSSLMode();
            // 'charset='.$this->GetCharset();
    # Set it
    $this->setDsn($_dsn);
    # Results
    return $this->pdo_dsn;
  }
1139806
protected function getDatabaseInformation()
    {
        $this->dbInfo['connection'] = env('DB_CONNECTION');
        $this->dbInfo['host'] = env('DB_HOST');
        $this->dbInfo['database'] = env('DB_DATABASE');
        $this->dbInfo['username'] = env('DB_USERNAME');
        $this->dbInfo['password'] = env('DB_PASSWORD');
        $this->dbInfo['port'] = env('DB_PORT');

        if (!check_db_connection()) {
            $this->error('Please setup your database information first!');
            die();
        }

        $this->info('Database OK...');
    }
464086
private function getConnectionString() {
        // supported keywords:  https://www.postgresql.org/docs/9.6/static/libpq-connect.html#LIBPQ-PARAMKEYWORDS
        $paramKeywords = [
            'host',
            'hostaddr',
            'port',
            'dbname',
            'user',
            'password',
            'connect_timeout',
            'client_encoding',
            'options',
            'application_name',
            'fallback_application_name',
            'keepalives',
            'keepalives_idle',
            'keepalives_interval',
            'keepalives_count',
            'tty',                                          // ignored
            'sslmode',
            'requiressl',                                   // deprecated in favor of 'sslmode'
            'sslcompression',
            'sslcert',
            'sslkey',
            'sslrootcert',
            'sslcrl',
            'requirepeer',
            'krbsrvname',
          //'gsslib',                                       // rejected by php_pgsql 9.4.1
            'service',
        ];
        $paramKeywords = \array_flip($paramKeywords);
        $connStr = '';

        foreach ($this->options as $key => $value) {
            $keyL = trim(strtolower($key));

            if (!isset($paramKeywords[$keyL])) continue;    // unknown keyword

            if (is_array($value)) {
                if ($keyL != 'options') continue;           // "options" is the only allowed keyword with nested settings

                // split regular connection options and session variables
                if (isset($value[''])) {
                    $this->options[$key] = $value[''];
                    unset($value['']);
                    $this->sessionVars = $value;
                    $value = $this->options[$key];          // the root value goes into the connection string
                }
                else {
                    unset($this->options[$key]);
                    $this->sessionVars = $value;
                    continue;                               // "options" has only session vars and no root value [""]
                }
            }

            if (!strlen($value)) {
                $value = "''";
            }
            else {
                $value = str_replace(['\\', "'"], ['\\\\', "\'"], $value);
                if (strContains($value, ' '))
                    $value = "'".$value."'";
            }
            $connStr .= $key.'='.$value.' ';
        }
        return trim($connStr);
    }
56075
public function connectionString()
    {
        if (empty($this->username) || empty($this->password)) {
            return sprintf(
                "mongodb://%s:%d/%s",
                $this->host,
                $this->port,
                $this->db
            );
        }
        return sprintf(
            "mongodb://%s:%s@%s:%d/%s",
            $this->username,
            $this->password,
            $this->host,
            $this->port,
            $this->db
        );
    }
242235
public function getDbConnectionCmd()
    {
        $dbParams = $this->getDbConnectionParams();
        
        $dbConnectionCmd = 'mysql -u ' . $dbParams['user']
                         . ' -h ' . $dbParams['host']
                         . ' -P ' . $dbParams['port'];
        
        if (strlen($dbParams['password']) > 0) {
            $dbConnectionCmd .= ' -p"' . $dbParams['password'] . '"';
        }
        
        return $dbConnectionCmd;
    }
162908
private function getConnection()
    {
        if (!isset($this->connections[$this->getDriver()])) {
            $this->connections[$this->getDriver()] = DriverManager::getConnection(
                array(
                    'driver' => $this->getDriver(),
                    'host' => str_replace('pdo_', '', $this->getDriver()),
                    'dbname' => 'list',
                    'user' => 'list',
                    'password' => 'list',
                    // 'unix_socket' => '/tmp/mysql.sock',
                )
            );
        }

        return $this->connections[$this->getDriver()];
    }
968636
public function getConnection()
    {
        if (is_null($this->_connection)) {
            $this->setConnection(
                Agl::app()->getConfig('main/db/host'),
                Agl::app()->getConfig('main/db/name'),
                Agl::app()->getConfig('main/db/user'),
                Agl::app()->getConfig('main/db/password')
            );
        }

        return $this->_connection;
    }
277793
public function getMainDB()
    {
        if ($this->main_database === null &&
            ($this->isOperationModeCLI() || $this->isOperationModeStandalone())
        ) {
            $this->registerMainDatabase();
        }
        return $this->main_database;
    }
1346122
public static function info()
    {
        $database = Config::get('database.database');
        $host = Config::get('database.host');
        $username = Config::get('database.username');
        //
        return "\n\n-- Database : $database\n-- Host : $host\n-- User : $username\n";
    }
97167
public function getDsn()
    {
        if ($this->checkParam()) {
            $sDsn = 'sqlsrv:';
            if (!empty($this->getApplication())) {
                $sDsn .= 'APP=' . $this->getApplication() . ';';
            }
            if (!empty($this->getConnectionPooling())) {
                $sDsn .= 'ConnectionPooling=' . $this->getConnectionPooling() . ';';
            }
            if (!empty($this->getDatabase())) {
                $sDsn .= 'Database=' . $this->getDatabase() . ';';
            }
            if (!empty($this->getEncrypt())) {
                $sDsn .= 'Encrypt=' . $this->getEncrypt() . ';';
            }
            if (!empty($this->getFailoverPartner())) {
                $sDsn .= 'FailoverPartner=' . $this->getFailoverPartner() . ';';
            }
            if (!empty($this->getLoginTimeout())) {
                $sDsn .= 'LoginTimeout=' . $this->getLoginTimeout() . ';';
            }
            if (!empty($this->getMultipleActiveResultSets())) {
                $sDsn .= ' MultipleActiveResultSets=' . $this->getMultipleActiveResultSets() . ';';
            }
            if (!empty($this->getQuotedId())) {
                $sDsn .= 'QuotedId=' . $this->getQuotedId() . ';';
            }
            if (!empty($this->getHost())) {
                $sDsn .= 'Server=' . $this->getHost();
                if (!empty($this->getPort())) {
                    $sDsn .= ',' . $this->getPort();
                }
                $sDsn .= ';';
            }
            if (!empty($this->getTraceFile())) {
                $sDsn .= 'TraceFile=' . $this->getTraceFile() . ';';
            }
            if (!empty($this->getTraceOn())) {
                $sDsn .= 'TraceOn=' . $this->getTraceOn() . ';';
            }
            if (!empty($this->getTransactionIsolation())) {
                $sDsn .= 'TransactionIsolation=' . $this->getTransactionIsolation() . ';';
            }
            if (!empty($this->getTrustServerCertificate())) {
                $sDsn .= 'TrustServerCertificate=' . $this->getTrustServerCertificate() . ';';
            }
            if (!empty($this->getWsid())) {
                $sDsn .= 'WSID=' . $this->getWsid() . ';';
            }
            return $sDsn;
        } else {
            return false;
        }
    }
196024
protected function dbName()
    {

        $dbName = "default";
        $config = $this::$config;
        $configs = ConnectionManager::config($config);
        if ($configs) {
            $dbName = $configs['connection']['database'];
        }

        return $dbName;
    }