public function run($sql, array $params = [], bool $returnStatement = false, int $fetchMode = PDO::FETCH_ASSOC)
    {
        if ($sql instanceof Query) {
            $params = $sql->getParams();
            $sql = $sql->getSql();
        }

        $stm = $this->prepare($sql);
        $stm->execute($params);
        $this->logQuery($sql, $params);

        if ($returnStatement) {
            return $stm;
        } elseif (substr(trim($sql), 0, 6) === 'SELECT') {
            return $stm->fetchAll($fetchMode);
        } else {
            return $stm->rowCount();
        }
    }