public function endTransaction($commit)
    {
        if ($commit) {
            $result = $this->commit();
        } else {
            $result = $this->rollback();
        }

        switch ($this->mode) {

            case "mysql":
                if (!$this->server->autocommit(true)) {
                    $result = false;
                }
                break;

            case "postgres":
                $result = $this->query("SET AUTOCOMMIT = ON");
                break;

            case "redshift":
                # Do nothing, and use the result from the commit/rollback
                break;

            case "odbc":
                if (!odbc_autocommit($this->server, true)) {
                    $result = false;
                }
                break;

            default:
                throw new \Exception("endTransaction() not supported in this mode (" . $this->mode . ")");
        }

        if (!$result) {
            $this->error();
        }

        $this->transaction = false;

        return true;
    }