public function execute(array $params) : ResultSet
    {
        $this->logger->info('DB PREPARE: Preparing query.');
        $test_query = $this->result->queryString;
        foreach ($params as $name => $val) {
            $test_query = str_replace($name, '\'' . str_replace("'", "''", $val) . '\'', $test_query);
        }
        $this->logger->info('DB QUERY: ' . $this->result->queryString);
        $this->result->execute($params);
        if (null === $this->result->errorCode()) {
            // Something really bad happened
            $this->logger->info('PARAMS: ' . implode('|', $params));
            $this->logger->error('DB ERROR: The query could not be executed - unknown error.');
            $this->logger->debug('Test Query: ' . $test_query);
            throw new DatabaseQueryException($this->result->errorInfo()[2]);
        } elseif (preg_match('/^00000$/', $this->result->errorCode())) {
            // The query was successful
            $this->logger->debug('DB Success: ' . implode('|', $params));
        } elseif (preg_match('/^(00|01)/', $this->result->errorCode())) {
            // A warning was thrown
            $this->logger->info('PARAMS: ' . implode('|', $params));
            $this->logger->warning('DB WARN: ' . $this->result->errorCode() . ' -- ' . $this->result->errorInfo()[2]);
            $this->logger->debug('Test Query: ' . $test_query);
        } else {
            // The query failed
            $this->logger->info('PARAMS: ' . implode('|', $params));
            $this->logger->error('DB ERROR: ' . $this->result->errorCode() . ' -- ' . $this->result->errorInfo()[2]);
            $this->logger->debug('Test Query: ' . $test_query);
            throw new DatabaseQueryException($this->result->errorInfo()[2]);
        }
        return $this;
    }