Changeset 21765 for lang/perl/App-Hachero
- Timestamp:
- 10/21/08 11:09:09 (5 years ago)
- Location:
- lang/perl/App-Hachero/trunk
- Files:
-
- 1 added
- 1 modified
-
lib/App/Hachero/Plugin/Output/DBIC.pm (modified) (3 diffs)
-
t/plugin/output/02_dbic_countup.t (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/App-Hachero/trunk/lib/App/Hachero/Plugin/Output/DBIC.pm
r21618 r21765 8 8 my $schema = App::Hachero::Plugin::Output::DBIC::Schema 9 9 ->connect(@{$self->config->{config}->{connect_info}}); 10 my $update_mode = $self->config->{config}->{update_mode}; 10 11 unless ($schema) { 11 12 $context->log(error => "connection error"); … … 23 24 for my $data ($result->values) { 24 25 eval { 25 $rs->update_or_create($data->hashref) 26 my $hashref = $data->hashref; 27 if ( $update_mode eq 'count_up' ) { 28 my $count = delete $hashref->{count}; 29 my $rec = $rs->find_or_create($hashref); 30 $rec->update({count => ($rec->count || 0) + $count}); 31 } else { 32 $rs->update_or_create($hashref) 33 } 26 34 }; 27 35 if ($@) { … … 56 64 - module: Output::DBIC 57 65 config: 66 update_mode: [count_up|overwrite] 58 67 connect_info: 59 68 - dbi:mysql:dbhost=db.local;dbname=logdb 60 69 - your_name 61 70 - your_password 71 62 72 63 73 =head1 DESCRIPTION
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)