public function setQuery(string $query, ?PDO $db = null)
    {
        if ($db == null) {
            $db = MDbConnection::getDbConnection();
        }

        if ($db instanceof \PDO) {
            $this->query = new MPDOQuery($query, $db);
        } else {
            throw new \Exception("Database connection not supported.");
        }

        $this->query->exec();
    }