The code:
class myModel extends Phalcon\Mvc\Model
{
public function beforeSave()
{
$this->getDi()->getShared('db')->begin();
}
...
public function afterSave()
{
$this->getDi()->getShared('db')->commit();
}
}
My question is - what happens if along the way, between beforeSave() and afterSave() there's an Exception thrown - how can I cleanly roll back the transaction? Where should I stick $this->getDi()->getShared('db')->rollback(); in to?
Thanks!