Revision d49485e0
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/DB/Object.pm | ||
---|---|---|
110 | 110 |
|
111 | 111 |
sub save { |
112 | 112 |
my ($self, @args) = @_; |
113 |
my $worker = sub { |
|
113 |
|
|
114 |
my $result; |
|
115 |
my $worker = sub { |
|
114 | 116 |
SL::DB::Object::Hooks::run_hooks($self, 'before_save'); |
115 |
my $result = $self->SUPER::save(@args);
|
|
117 |
$result = $self->SUPER::save(@args); |
|
116 | 118 |
SL::DB::Object::Hooks::run_hooks($self, 'after_save', $result); |
117 | 119 |
}; |
118 | 120 |
|
119 |
return $self->db->in_transaction ? $worker->() : $self->db->do_transaction($worker); |
|
121 |
$self->db->in_transaction ? $worker->() : $self->db->do_transaction($worker); |
|
122 |
return $result; |
|
120 | 123 |
} |
121 | 124 |
|
122 | 125 |
sub delete { |
123 | 126 |
my ($self, @args) = @_; |
124 |
my $worker = sub { |
|
127 |
|
|
128 |
my $result; |
|
129 |
my $worker = sub { |
|
125 | 130 |
SL::DB::Object::Hooks::run_hooks($self, 'before_delete'); |
126 |
my $result = $self->SUPER::delete(@args);
|
|
131 |
$result = $self->SUPER::delete(@args); |
|
127 | 132 |
SL::DB::Object::Hooks::run_hooks($self, 'after_delete', $result); |
128 | 133 |
}; |
129 | 134 |
|
130 |
return $self->db->in_transaction ? $worker->() : $self->db->do_transaction($worker); |
|
135 |
$self->db->in_transaction ? $worker->() : $self->db->do_transaction($worker); |
|
136 |
return $result; |
|
131 | 137 |
} |
132 | 138 |
|
133 | 139 |
1; |
Auch abrufbar als: Unified diff
Bei save/delete das richtige Ergebnis zurückgeben
Und zwar das von RDBO::save/delete, und nicht das von do_transaction.