getConnectionString

Return the connection string.

@return string
170293
public function getConnectionString()
    {
        $this->parseDsn();
        $connect_parameters = [
            sprintf(
                "user=%s dbname=%s",
                $this->configuration['user'],
                $this->configuration['database']
            )
        ];

        if ($this->configuration['host'] !== '') {
            $connect_parameters[] = sprintf('host=%s', $this->configuration['host']);
        }

        if ($this->configuration['port'] !== '') {
            $connect_parameters[] = sprintf('port=%s', $this->configuration['port']);
        }

        if ($this->configuration['pass'] !== '') {
            $connect_parameters[] = sprintf('password=%s', addslashes($this->configuration['pass']));
        }

        return join(' ', $connect_parameters);
    }
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
        );
    }
709733
@Override
    public String getConnectionInfo() {
        return String.format("Table Name - %s : Attribute Name - %s : Consistent Read - %b",
                this.config.getTableName(),
                this.config.getAttributeName(),
                this.config.consistentRead());
    }
1033160
public function getConnection()
    {
        if (empty($this->connection)) {

            if (empty($this->connectionConfig) || !is_array($this->connectionConfig))
                throw new DatabaseException("Connection config is empty or not an array.");

            $connCount = count($this->connectionConfig);
            for($i = 0; $i < $connCount; ++$i)
            {
                $connectionInfo = $this->connectionConfig[$i];

                if (empty($connectionInfo['port']))
                    $connectionInfo['port'] = 3306;

                $dsn = "mysql:dbname={$connectionInfo['database']};host={$connectionInfo['host']};port={$connectionInfo['port']}";
                if (!empty($connectionInfo['unix_socket']))
                    $dsn .= ';unix_socket='.$connectionInfo['unix_socket'];

                try {

                    $trx_attempt = 0;
                    while ($trx_attempt < $this->deadlockRetries) {

                        try {

                            $this->connection = new PDO($dsn, $connectionInfo['username'], $connectionInfo['password'], array(
                                PDO::ATTR_PERSISTENT => (!empty($connectionInfo['persistent'])?StringUtils::strToBool($connectionInfo['persistent']):false),
                                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                                PDO::ATTR_CASE => PDO::CASE_NATURAL,
                                PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
                                PDO::MYSQL_ATTR_DIRECT_QUERY => true,
                                PDO::ATTR_TIMEOUT => (!empty($connectionInfo['timeout'])?$connectionInfo['timeout']:30) ));


                            $this->connDebugString = $connectionInfo['host'].':'.$connectionInfo['database'];
                            $this->currentDBName = $connectionInfo['database'];

                            $this->Logger->debug(array(
                                'SQL'                    => 'CONNECTION - DB: '.$this->connDebugString,
                            ));

                            return $this->connection;

                        } catch (PDOException $pe) {
                            if ((strpos($pe->getMessage(), 'Too many connections') !== FALSE) && ++$trx_attempt < $this->deadlockRetries)
                            {
                                usleep( pow(2,$trx_attempt) * 100000 );
                                continue;
                            }

                            throw $pe;
                        }
                    }

                } catch(PDOException $pe)
                {

                    // if the last connection fails
                    if($i == ($connCount-1))
                        throw new SQLConnectionException($pe->getMessage());
                }
            }
        }

        return $this->connection;
    }
1137206
public function getConnectionString(){
        $connection_string = array();

        $type = $this->getType();
        array_push($connection_string, $type);

        if($type == self::SQLite){
        	$filename = 'db.sqlite';
        	if(isset($this->properties['filename']))
        		$filename = $this->properties['filename'];
        	array_push($connection_string, ":$filename");
        }
        else {
	        array_push($connection_string, ':host=');
	        array_push($connection_string,
	            (isset($this->properties['host']))?
	            $this->properties['host']:'localhost'
	        );
	        array_push($connection_string, ';dbname=');
	        array_push($connection_string,
	            (isset($this->properties['name']))?
	            $this->properties['name']:null
	        );
        }
        
        array_push($connection_string, ';charset=');
        array_push($connection_string, $this->getCharset());
        return implode($connection_string);
    }
99741
public function getConn()
    {
        if ($this->conn === null) {
            $this->conn = Connection::connect($this->req->getUrlParam('conn'), $this);
            if ($this->conn === false) {
                $this->res->error = Connection::getLastError();
                $this->finish();
            } else {
                if ($this->conn !== null) {
                    $this->conn->addWriteData($this->getRequestBuf());
                }
            }
        }
        return $this->conn;
    }
1320933
public function getConnection()
    {
        if (! $this->connection) {
            list($dns, $username, $password) = $this->connectionString();

            $this->setConnection(new \PDO($dns, $username, $password));
        }

        return $this->connection;
    }
1022564
final String getConnectionDescription() {

      if(datasource != null) {
         return name;
      }

      String description = connectionString;
      int index = connectionString != null ? connectionString.indexOf('?') : 0;
      if(index > 0) {
         description = connectionString.substring(0, index);
      }

      if(!Strings.isNullOrEmpty(user)) {
         return user + "@" + description;
      } else {
         return description;
      }
   }
738112
public function toString()
	{
		return $this->connection
		            ->prepare($this->buildQuery($this->type))
		            ->bind($this->syntax->getBindings())
		            ->toString();
	}
611581
protected function pgsqlConnectionString()
    {
        return $this->driver . ':host=' . $this->host . ';port=' . $this->port . ';dbname=' . $this->dbname . ';user=' . $this->user . ';password=' . $this->password;
    }
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;
    }
979750
public function getConnection()
    {
        if ($this->_oConn === null) {
            $this->_oConn = $this->openDatabase(null);
        }

        return $this->_oConn;
    }
18588
public function getConnection() {
		try {
			$pdo = null;

			switch($this->driver){
				case "pdo_mysql": // MySQL Database
					$pdo = new PDO("mysql:host=".$this->host.";dbname=".$this->database.";charset=utf8", $this->user, $this->password);
					break;
				case "pdo_sqlserver": // SQL Server Database
					$pdo = new PDO("sqlsrv:Server=".$this->host.";Database=".$this->database, $this->user, $this->password);
					break;
				case "pdo_sqlite": // SQLite Database
				    $pdo = new PDO("sqlite:{$this->database}");
					break;
				case "pdo_pgsql": // PostgreSQL Database
				    $pdo = new PDO("pgsql:dbname={$this->database};host={$this->host}", $this->user, $this->password);
				    break;
				case "pdo_oci": // Oracle Database
					$tns = "oci:dbname=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (Host = {$this->host}) (Port = {$this->port}))) (CONNECT_DATA = (SERVICE_NAME = {$this->database})))";
					$pdo = new PDO($tns, $this->user, $this->password);
					break;
				default:
					throw new  Exception("Database driver not defined");
				}

				if (count($this->attributes) > 0) {
					foreach ($this->attributes as $key => $value) {
						$pdo->setAttribute($key, $value);
					}
				}

				$this->pdo = $pdo;

				return $pdo;

		} catch (PDOException $e) {
			throw new PDOException('Unable to connect to database, errorMessage = '.$e->getMessage());
		} catch (Exception $e) {
			throw new Exception('Internal error, errorMessage = '.$e->getMessage());
		}
	}
364007
public function getConnection()
    {
        if ($this->connection instanceof ConnectionInterface === FALSE)
        {
            $this->connection = Propel::getConnection();
        }

        return $this->connection;
    }
855864
public function getConnection()
    {
        $repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();
        // Taking provided connection name if any.
        // Otherwise, just fallback to the default connection.

        if (isset($repositoryConfig['search']['connection'])) {
            $doctrineConnectionId = sprintf('doctrine.dbal.%s_connection', $repositoryConfig['search']['connection']);
        } else {
            // "database_connection" is an alias to the default connection, set up by DoctrineBundle.
            $doctrineConnectionId = 'database_connection';
        }

        if (!$this->container->has($doctrineConnectionId)) {
            throw new InvalidArgumentException(
                "Invalid Doctrine connection '{$repositoryConfig['search']['connection']}' for repository '{$repositoryConfig['alias']}'." .
                'Valid connections are ' . implode(', ', array_keys($this->container->getParameter('doctrine.connections')))
            );
        }

        return $this->container->get($doctrineConnectionId);
    }
1365233
public function
	GetDSN() {
	/*//
	@type string
	get the connection dsn string for this database connection.
	//*/

		switch(strtolower($this->Type)) {
			case 'mysql': return sprintf(
				'%s:host=%s;dbname=%s;charset=%s',
				$this->Type,
				$this->Hostname,
				$this->Database,
				$this->Charset
			);
			case 'sqlite': return sprintf(
				'%s:%s',
				$this->Type,
				$this->Database
			);
			default: return sprintf(
				'%s:host=%s;dbname=%s, %s, %s;charset=%s',
				$this->Type,
				$this->Hostname,
				$this->Database,
				$this->Username,
				$this->Password,
				$this->Charset
			);
		}
	}
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;
    }