public function getConnectionString()
    {

        $dsn = 'mysql:';

        // get the connection settings local so there is less function call overhead
        $connectionSettings = $this->getConnectionSettings();
        if ($this->isSocket()) {
            $dsn .= (string)'unix_socket=' . $connectionSettings->getHost() . ';';
        } else {
            $dsn .= (string)'host=' . $connectionSettings->getHost() . ';';
            if ($connectionSettings->getPort()) {
                $dsn .= 'port=' . $connectionSettings->getPort() . ';';
            }
        }

        if ($connectionSettings->getDatabase()) {
            $dsn .= "dbname=" . $connectionSettings->getDatabase() . ';';
        }

        if ($connectionSettings->getCharset()) {
            $dsn .= "charset=" . $connectionSettings->getCharset() . ';';
        }

        return $dsn;
    }