Create the message we want to throw, if there was a connection error.

@param Connection $connection The connection.

@return string The message we want throw if there was a connection error.
330452
protected function createConnectionErrorMessage($connection)
    {
        $message =
            'Not connected to database. dsn: ' .
            $connection->getDriver()->getName() .
            '://' .
            '****:****@' .
            $connection->getHost() . ':' . $connection->getPort() .
            '/' . $connection->getDatabase();

        return $message;
    }
545436
protected function makeCommand($connection, $connectionName)
    {
        $cmd[] = 'mysqldump -u ' . $connection['username'];
        $cmd[] = '--password=' . $connection['password'];
        $cmd[] = $connection['database'];
        $cmd[] = ' -h ' . $connection['host'];
        if ( ! empty($connection['port'])) {
            $cmd[] = '-P ' . $connection['port'];
        }
        $cmd[] = '> ' . $this->filename($connectionName);
        return implode(' ', $cmd);
    }
293394
public function createDriverByConnection($connection = null)
    {
        $connection = $connection ?: $this->getConnectionName();

        $config = $this->getConnectionConfig($connection);

        return $this->createDriver($config->get('driver', 'sync'), $config->toArray());
    }
280887
private static function setConnectionCharset(Connection $connection, array $options = array())
    {
        if (isset($options['charset'])) {
            try {
                if ('pdo_mysql' === $connection->getDriver()->getName()) {
                    $connection->executeQuery('SET SESSION character_set_client = "'.addslashes($options['charset']).'";');
                    $connection->executeQuery('SET SESSION character_set_connection = "'.addslashes($options['charset']).'";');
                    $connection->executeQuery('SET SESSION character_set_results = "'.addslashes($options['charset']).'";');
                }
            } catch (\Exception $e) {
                throw new InvalidArgumentException(
                    sprintf('Invalid database character set `%s`', $options['charset']),
                    InvalidArgumentException::INVALID_ARGUMENT,
                    $e
                );
            }
        }
    }
629327
protected function getConnection($connection = null)
    {
        $database = $this->app->make('db');

        $connection = $connection ?: $database->getDefaultConnection();

        return $database->connection($connection);
    }
1119794
public function return_connection($connection) {
        if ($connection->op_count >= $this->recycle) {
            $this->stats['recycled'] += 1;
            $connection->close();
            $this->make_conn();
            $connection = $this->get();
        }
        array_push($this->queue, $connection);
    }
724163
public function onMessage($connection)
    {
        // REQUEST_URI.
        $workerman_url_info = parse_url('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
        if (!$workerman_url_info) {
            Http::header('HTTP/1.1 400 Bad Request');
            $connection->close('<h1>400 Bad Request</h1>');
            return;
        }

        $workerman_path = isset($workerman_url_info['path']) ? $workerman_url_info['path'] : '/';

        $workerman_path_info      = pathinfo($workerman_path);
        $workerman_file_extension = isset($workerman_path_info['extension']) ? $workerman_path_info['extension'] : '';
        if ($workerman_file_extension === '') {
            $workerman_path           = ($len = strlen($workerman_path)) && $workerman_path[$len - 1] === '/' ? $workerman_path . 'index.php' : $workerman_path . '/index.php';
            $workerman_file_extension = 'php';
        }

        $workerman_siteConfig = isset($this->serverRoot[$_SERVER['SERVER_NAME']]) ? $this->serverRoot[$_SERVER['SERVER_NAME']] : current($this->serverRoot);
		$workerman_root_dir = $workerman_siteConfig['root'];
        $workerman_file = "$workerman_root_dir/$workerman_path";
		if(isset($workerman_siteConfig['additionHeader'])){
			Http::header($workerman_siteConfig['additionHeader']);
		}
        if ($workerman_file_extension === 'php' && !is_file($workerman_file)) {
            $workerman_file = "$workerman_root_dir/index.php";
            if (!is_file($workerman_file)) {
                $workerman_file           = "$workerman_root_dir/index.html";
                $workerman_file_extension = 'html';
            }
        }

        // File exsits.
        if (is_file($workerman_file)) {
            // Security check.
            if ((!($workerman_request_realpath = realpath($workerman_file)) || !($workerman_root_dir_realpath = realpath($workerman_root_dir))) || 0 !== strpos($workerman_request_realpath,
                    $workerman_root_dir_realpath)
            ) {
                Http::header('HTTP/1.1 400 Bad Request');
                $connection->close('<h1>400 Bad Request</h1>');
                return;
            }

            $workerman_file = realpath($workerman_file);

            // Request php file.
            if ($workerman_file_extension === 'php') {
                $workerman_cwd = getcwd();
                chdir($workerman_root_dir);
                ini_set('display_errors', 'off');
                ob_start();
                // Try to include php file.
                try {
                    // $_SERVER.
                    $_SERVER['REMOTE_ADDR'] = $connection->getRemoteIp();
                    $_SERVER['REMOTE_PORT'] = $connection->getRemotePort();
                    include $workerman_file;
                } catch (\Exception $e) {
                    // Jump_exit?
                    if ($e->getMessage() != 'jump_exit') {
                        Worker::safeEcho($e);
                    }
                }
                $content = ob_get_clean();
                ini_set('display_errors', 'on');
                if (strtolower($_SERVER['HTTP_CONNECTION']) === "keep-alive") {
                    $connection->send($content);
                } else {
                    $connection->close($content);
                }
                chdir($workerman_cwd);
                return;
            }

            // Send file to client.
            return self::sendFile($connection, $workerman_file);
        } else {
            // 404
            Http::header("HTTP/1.1 404 Not Found");
			if(isset($workerman_siteConfig['custom404']) && file_exists($workerman_siteConfig['custom404'])){
				$html404 = file_get_contents($workerman_siteConfig['custom404']);
			}else{
				$html404 = '<html><head><title>404 File not found</title></head><body><center><h3>404 Not Found</h3></center></body></html>';
			}
            $connection->close($html404);
            return;
        }
    }
361024
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;
    }
1167090
public function getManager($connection = null)
    {
        $connection = $connection ? strtolower($connection) : 'default';

        if (!isset($this->managers[$connection])) {
            $this->managers[$connection] = $this->create($connection);
        }

        return $this->managers[$connection];
    }
704407
public function getConnection($connection = null)
    {
        if ($connection) {
            $this->connection = $connection;
        }

        return Redis::connection($this->connection);
    }
686729
protected function onConnectionError($message, $code = null)
    {
        CommunicationException::handle(
            new ConnectionException($this, static::createExceptionMessage($message), $code)
        );
    }
63945
protected function checkMySqlDatabaseSize($connection)
    {
        try {
            $result = (array) DB::connection($connection)
                                ->table('information_schema.TABLES')
                                ->select(DB::raw("sum( data_length + index_length ) AS size"))
                                ->where('table_schema', DB::connection($connection)->getConfig('database'))
                                ->first();

            return $result['size'];
        } catch (Exception $e) {
            $this->eye->logger()->debug('Error during mySQL DB size check', ['exception' => $e->getMessage(), 'connection' => $connection]);
        }

        return -1;
    }
851798
function ErrorMsg()
	{
		if (!$this->_connectionID) return "No connection established";
		$errc = $this->_connectionID->Errors;
		if (!$errc) return "No Errors object found";
		if ($errc->Count == 0) return '';
		$err = $errc->Item($errc->Count-1);
		return $err->Description;
	}
1027664
protected function parseConnection($connection)
    {
        $pos  = strpos($connection, '=');
        $name = substr($connection, 0, $pos);
        $dsn  = substr($connection, $pos + 1, strlen($connection));

        $pos  = strpos($dsn, ':');
        $adapter = substr($dsn, 0, $pos);

        $extras = [];
        foreach (explode(';', $dsn) as $element) {
            $parts = preg_split('/=/', $element);

            if (2 === count($parts)) {
                $extras[strtolower($parts[0])] = urldecode($parts[1]);
            }
        }
        $extras['adapter'] = $adapter;

        return [$name, $dsn, $extras];
    }
270629
public function initConnection(Connection $connection)
    {
        /** @var $pdo PDO */
        $pdo = $connection->getWrappedConnection();
        $this->fkSupported = version_compare('3.6.19', $pdo->getAttribute(PDO::ATTR_SERVER_VERSION)) < 0;
        $pdo->exec($this->buildEnableForeignKeysQuery());
    }
484791
protected static function getSchemaBuilder(Connection $connection)
    {
        $schemaBuilder = $connection->getSchemaBuilder();
        $schemaBuilder->blueprintResolver(function ($table, $callback) {
            return new Blueprint($table, $callback);
        });

        return $schemaBuilder;
    }
1336563
function ErrorMsg()
	{
		if (!$this->_connectionID) return "No connection established";
		$errmsg = '';

		try {
			$errc = $this->_connectionID->Errors;
			if (!$errc) return "No Errors object found";
			if ($errc->Count == 0) return '';
			$err = $errc->Item($errc->Count-1);
			$errmsg = $err->Description;
		}catch(exception $e) {
		}
		return $errmsg;
	}