/** * Duas operações com objetos diferentes, usando a mesma transação */ public function nestedTransactions() { try { $transaction = $this->beginTransaction(); $this->getById(1); $this->save(); // cria um novo usuário com um novo setor $setor = new Setor(); $setor->novo('NOVO SETOR'); $this->setPersistent(false); $this->setIdSetor($setor->getIdSetor()); $this->save(); $transaction->commit(); } catch (EModelException $e) { $transaction->rollback(); throw new EModelException($e->getMessage()); } }