From b6a07b65a544a8152d35b0ee8b39448d42eb93e1 Mon Sep 17 00:00:00 2001 From: doctrine Date: Mon, 29 May 2006 20:08:28 +0000 Subject: [PATCH] PDOException now wrapped into Doctrine_Exception, transaction rollback whenever PDOException is thrown --- classes/Session.class.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/classes/Session.class.php b/classes/Session.class.php index 814290b37..0d5d8d60c 100644 --- a/classes/Session.class.php +++ b/classes/Session.class.php @@ -472,18 +472,24 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab if($this->getAttribute(Doctrine::ATTR_VLD)) $this->validator = new Doctrine_Validator(); + try { + + $this->bulkInsert(); + $this->bulkUpdate(); + $this->bulkDelete(); - $this->bulkInsert(); - $this->bulkUpdate(); - $this->bulkDelete(); - - if($this->getAttribute(Doctrine::ATTR_VLD)) { - if($this->validator->hasErrors()) { - $this->rollback(); - throw new Doctrine_Validator_Exception($this->validator); + if($this->getAttribute(Doctrine::ATTR_VLD)) { + if($this->validator->hasErrors()) { + $this->rollback(); + throw new Doctrine_Validator_Exception($this->validator); + } } + + } catch(PDOException $e) { + $this->rollback(); + + throw new Doctrine_Exception($e->getMessage()); } - $this->dbh->commit(); $this->getAttribute(Doctrine::ATTR_LISTENER)->onTransactionCommit($this);