protected function query(string $sql, array $params = [], array $options = []): \PDOStatement {
        $options += [
            Db::OPTION_FETCH_MODE => $this->getFetchArgs()
        ];

        $stm = $this->getPDO()->prepare($sql);


        if ($options[Db::OPTION_FETCH_MODE]) {
            $stm->setFetchMode(...(array)$options[Db::OPTION_FETCH_MODE]);
        }

        $r = $stm->execute($params);

        // This is a kludge for those that don't have errors turning into exceptions.
        if ($r === false) {
            list($state, $code, $msg) = $stm->errorInfo();
            throw new \PDOException($msg, $code);
        }

        return $stm;
    }