+class Model_Badge extends \Orm\Model_Soft
+public function delete($cascade = null, $use_transaction = false)
+ // New objects can't be deleted, neither can frozen
+ if ($this->is_new() or $this->frozen())
+ $db = \Database_Connection::instance(static::connection(true));
+ $db->start_transaction();
+ $this->observe('before_delete');
+ // Delete the model in question
+ if ( ! $this->delete_self())
+ // remove from internal object cache, remove PK's, set to non saved object, remove db original values
+ if (array_key_exists(get_called_class(), static::$_cached_objects)
+ and array_key_exists(static::implode_pk($this), static::$_cached_objects[get_called_class()]))
+ unset(static::$_cached_objects[get_called_class()][static::implode_pk($this)]);
+ foreach ($this->primary_key() as $pk)
+ unset($this->_data[$pk]);
+ $this->_original = array();
+ $this->observe('after_delete');
+ $use_transaction and $db->commit_transaction();
+ $use_transaction and $db->rollback_transaction();