public function transaction(\Closure $callback): Transaction
    {
        /**
         * Get the Transaction class
         *
         * @var \Pecee\Pixie\QueryBuilder\Transaction $queryTransaction
         * @throws \Exception
         */
        $queryTransaction = new Transaction($this->connection);
        $queryTransaction->statements = $this->statements;

        try {
            // Begin the PDO transaction
            if ($this->pdo()->inTransaction() === false) {
                $this->pdo()->beginTransaction();
            }

            // Call closure - this callback will return TransactionHaltException if user has already committed the transaction
            $callback($queryTransaction);

            // If no errors have been thrown or the transaction wasn't completed within the closure, commit the changes
            $this->pdo()->commit();

        } catch (TransactionHaltException $e) {

            // Commit or rollback behavior has been triggered in the closure
            return $queryTransaction;

        } catch (\Exception $e) {

            // Something went wrong. Rollback and throw Exception
            if ($this->pdo()->inTransaction() === true) {
                $this->pdo()->rollBack();
            }

            throw Exception::create($e, $this->getConnection()->getAdapter()->getQueryAdapterClass(), $this->getLastQuery());
        }

        return $queryTransaction;
    }