parseDSN() public static method

Additional keys can be added by appending a URI query string to the end of the DSN. The format of the supplied DSN is in its fullest form: driver://user:password@protocol+host/database?option=8&another=true Most variations are allowed: driver://user:password@protocol+host:110//usr/db_file.db?mode=0644 driver://user:password@host/dbname driver://user:password@host driver://user@host driver://host/dbname driver://host driver This function is 'borrowed' from PEAR /DB.php .
public static parseDSN ( string $dsn ) : array
$dsn string Data Source Name to be parsed
return array an associative array with the following keys: + driver: Database backend used in PHP (mysql, odbc etc.) + host: Host specification (hostname[:port]) + dbname: Database to use on the DBMS server + username: User name for login + password: Password for login
Example #1
0
 public function setUp()
 {
     $dsn = getenv('DATABASE');
     if (!$dsn) {
         $dsn = 'sqlite://:memory:';
     }
     $doctrineParams = ConnectionHandler::parseDSN($dsn);
     $this->connection = DriverManager::getConnection($doctrineParams);
     $this->handler = new ConnectionHandler($this->connection);
 }
 /**
  * @dataProvider dataDsn
  */
 public function testParseDSN($expected, $dsn)
 {
     $this->assertEquals($expected, ConnectionHandler::parseDSN($dsn));
 }