|
Lines 194-199
sub delete {
Link Here
|
| 194 |
return $self->_resultset->delete; |
194 |
return $self->_resultset->delete; |
| 195 |
} |
195 |
} |
| 196 |
|
196 |
|
|
|
197 |
=head3 update |
| 198 |
|
| 199 |
=cut |
| 200 |
|
| 201 |
sub update { |
| 202 |
my ($self, $params) = @_; |
| 203 |
|
| 204 |
my $no_triggers = delete $params->{no_triggers}; |
| 205 |
|
| 206 |
if ( |
| 207 |
!$no_triggers |
| 208 |
&& ( Class::Inspector->function_exists( $self->object_class, 'update' ) |
| 209 |
or Class::Inspector->function_exists( $self->object_class, 'store' ) ) |
| 210 |
) |
| 211 |
{ |
| 212 |
my $objects_updated; |
| 213 |
$self->_resultset->result_source->schema->txn_do( sub { |
| 214 |
while ( my $o = $self->next ) { |
| 215 |
$o->update($params); |
| 216 |
$objects_updated++; |
| 217 |
} |
| 218 |
}); |
| 219 |
return $objects_updated; |
| 220 |
} |
| 221 |
|
| 222 |
return $self->_resultset->update($params); |
| 223 |
} |
| 224 |
|
| 197 |
=head3 single |
225 |
=head3 single |
| 198 |
|
226 |
|
| 199 |
my $object = Koha::Objects->search({}, { rows => 1 })->single |
227 |
my $object = Koha::Objects->search({}, { rows => 1 })->single |
|
Lines 474-487
The autoload method is used call DBIx::Class method on a resultset.
Link Here
|
| 474 |
|
502 |
|
| 475 |
Important: If you plan to use one of the DBIx::Class methods you must provide |
503 |
Important: If you plan to use one of the DBIx::Class methods you must provide |
| 476 |
relevant tests in t/db_dependent/Koha/Objects.t |
504 |
relevant tests in t/db_dependent/Koha/Objects.t |
| 477 |
Currently count, is_paged, pager, update, result_class, single and slice are covered. |
505 |
Currently count, is_paged, pager, result_class, single and slice are covered. |
| 478 |
|
506 |
|
| 479 |
=cut |
507 |
=cut |
| 480 |
|
508 |
|
| 481 |
sub AUTOLOAD { |
509 |
sub AUTOLOAD { |
| 482 |
my ( $self, @params ) = @_; |
510 |
my ( $self, @params ) = @_; |
| 483 |
|
511 |
|
| 484 |
my @known_methods = qw( count is_paged pager update result_class single slice ); |
512 |
my @known_methods = qw( count is_paged pager result_class single slice ); |
| 485 |
my $method = our $AUTOLOAD; |
513 |
my $method = our $AUTOLOAD; |
| 486 |
$method =~ s/.*:://; |
514 |
$method =~ s/.*:://; |
| 487 |
|
515 |
|
| 488 |
- |
|
|