/** * [getDsn description]. * * @return [type] [description] */ public function getDsn() { if (!$this->config) { return ''; } $dsn = array(); $path = null; if ($this->config->getName()) { $path = $this->config->getName(); } if ($this->config->getPath()) { $path = $this->config->getPath(); } if ($this->config->getHost()) { if ($this->config->getPort()) { $dsn[] = sprintf('dbname=%s/%s:%s', $this->config->getHost(), $this->config->getPort(), $path); } else { $dsn[] = sprintf('dbname=%s:%s', $this->config->getHost(), $path); } } else { $dsn[] = 'dbname=' . $path; } if ($this->config->getRole()) { $dsn[] = 'role=' . $this->config->getRole(); } if ($this->config->getChar()) { $dsn[] = 'charset=' . $this->config->getChar(); } return $this->getPrefix() . implode(';', $dsn); }
/** * [getDsn description]. * * @return [type] [description] */ public function getDsn() { if (!$this->config) { return ''; } $dsn = array(); $path = null; if ($this->config->getName()) { $path = $this->config->getName(); } if ($this->config->getPath()) { $path = $this->config->getPath(); } if ($path) { if (!file_exists($path)) { @touch($path); } $dsn[] = $path; } else { $dsn[] = ':memory:'; } return $this->getPrefix() . implode(';', $dsn); }