/** * Append the character set specifications to a command. * * @param string $sql * @param \Illuminate\Database\Connection $connection * @return string */ protected function compileCreateEncoding($sql, Connection $connection) { if (!is_null($charset = $connection->getConfig('charset'))) { $sql .= ' default character set ' . $charset; } if (!is_null($collation = $connection->getConfig('collation'))) { $sql .= ' collate ' . $collation; } return $sql; }
/** * Append the character set specifications to a command. * * @param string $sql * @param \Illuminate\Database\Connection $connection * @param \Illuminate\Database\Schema\Blueprint $blueprint * @return string */ protected function compileCreateEncoding($sql, Connection $connection, Blueprint $blueprint) { if (isset($blueprint->charset)) { $sql .= ' default character set ' . $blueprint->charset; } elseif (!is_null($charset = $connection->getConfig('charset'))) { $sql .= ' default character set ' . $charset; } if (isset($blueprint->collation)) { $sql .= ' collate ' . $blueprint->collation; } elseif (!is_null($collation = $connection->getConfig('collation'))) { $sql .= ' collate ' . $collation; } return $sql; }
/** * @param \Illuminate\Database\Connection $eloquentConnection * * @return \DreamFactory\Core\Database\Connection * @throws \DreamFactory\Core\Exceptions\InternalServerErrorException */ public static function getLegacyConnection($eloquentConnection) { if (empty(static::$connection)) { $driver = $eloquentConnection->getDriverName(); if (empty($driver)) { throw new InternalServerErrorException('No database driver supplied'); } $connections = config('database.connections'); if (empty($connections)) { throw new InternalServerErrorException('No connections found in database.connections config'); } $configKeys = []; foreach ($connections as $name => $connectionConfig) { if ($driver === $name || $driver === $connectionConfig['driver'] || $driver === 'dblib' && $name === 'sqlsrv') { $configKeys = array_keys($connectionConfig); } } if (empty($configKeys)) { throw new InternalServerErrorException('Unsupported driver - ' . $driver); } $config = []; foreach ($configKeys as $key) { $config[$key] = $eloquentConnection->getConfig($key); } switch ($driver) { case 'sqlite': $dsn = $driver . ":" . $config['database']; break; case 'mysql': $dsn = static::getMySqlDsn($config); break; case 'pgsql': $dsn = static::getPgSqlDsn($config); break; case 'sqlsrv': case 'dblib': $dsn = static::getSqlSrvDsn($config); break; default: throw new InternalServerErrorException('Unsupported driver - ' . $driver); break; } $config['dsn'] = $dsn; static::$connection = ConnectionFactory::createConnection($driver, $config); } return static::$connection; }
/** * Return whether or not the current database driver is SQLite. * * Useful for avoiding running queries that are not compatible with SQLite. * * @return bool */ protected function isSqlite() { return $this->db->getConfig('driver') == 'sqlite'; }