breakDSN() public static method

public static breakDSN ( $dsn )
Ejemplo n.º 1
0
 public function createDB($ds)
 {
     if (empty($ds)) {
         return;
     }
     $dbutil = new DBUtil();
     $user = @$ds['user'];
     $pass = @$ds['pass'];
     if (isset($ds['dsn'])) {
         $params = Utils::breakDSN($ds['dsn']);
         $ds = array_merge($ds, $params);
     }
     if (isset($ds[':memory:'])) {
         $this->logger->info('skip :memory: database');
         return;
     }
     if (!isset($ds['database'])) {
         $this->logger->notice('database is not defined.');
         return;
     }
     if (!isset($ds['host'])) {
         $ds['host'] = 'localhost';
     }
     $this->logger->info("creating database {$ds['database']}...");
     $dbutil->create($ds['driver'], array('username' => $user, 'password' => $pass, 'database' => $ds['database'], 'host' => $ds['host']));
 }
Ejemplo n.º 2
0
 public function testSqliteMemDSN()
 {
     $params = Utils::breakDSN('sqlite::memory:');
     $this->assertEquals('sqlite', $params['driver']);
     ok($params[':memory:']);
 }