/** * get the dsn connection string that PDO will use to connect to the backend * * @link http://us3.php.net/manual/en/ref.pdo-sqlite.php * @since 10-18-10 * @param string $name the database name * @param string $host the host * @return string the dsn */ protected function getDsn(MingoConfig $config) { // canary if (!$config->hasName()) { throw new InvalidArgumentException('no name specified'); } //if // for sqlite: PRAGMA encoding = "UTF-8"; from http://sqlite.org/pragma.html only good on db creation // http://stackoverflow.com/questions/263056/how-to-change-character-encoding-of-a-pdo-sqlite-connection-in-php return sprintf('sqlite:%s', $config->getName()); }
/** * get the dsn connection string that PDO will use to connect to the backend * * @since 10-18-10 * @param \MingoConfig $config * @return string the dsn */ protected function getDsn(MingoConfig $config) { // canary... if (!$config->hasHost()) { throw new InvalidArgumentException('no host specified'); } //if if (!$config->hasName()) { throw new InvalidArgumentException('no name specified'); } //if return sprintf('pgsql:dbname=%s;host=%s;port=%s', $config->getName(), $config->getHost(), $config->getPort(5432)); }
/** * get the dsn connection string that PDO will use to connect to the backend * * @link http://us2.php.net/manual/en/ref.pdo-mysql.php * @link http://us2.php.net/manual/en/ref.pdo-mysql.connection.php * @since 10-18-10 * @param \MingoConfig $config * @return string the dsn */ protected function getDsn(MingoConfig $config) { // canary... if (!$config->hasHost()) { throw new InvalidArgumentException('no host specified'); } //if if (!$config->hasName()) { throw new InvalidArgumentException('no name specified'); } //if // charset is actually ignored <5.3.6 return sprintf('mysql:host=%s;dbname=%s;charset=%s', $config->getHost(), $config->getName(), $this->charset); }