line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SPOPS::Import::DBI::Update; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Update.pm,v 1.1 2004/06/01 14:46:09 lachoy Exp $ |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
861
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw( SPOPS::Import::DBI::GenericOperation ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
725
|
|
7
|
|
|
|
|
|
|
use SPOPS::SQLInterface; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$SPOPS::Import::DBI::Update::VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my @FIELDS = qw( field field_value ); |
12
|
|
|
|
|
|
|
SPOPS::Import::DBI::Update->mk_accessors( @FIELDS ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub data { return [] } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _run_operation { |
17
|
|
|
|
|
|
|
my ( $self, $update_args ) = @_; |
18
|
|
|
|
|
|
|
$update_args->{field} = $self->field; |
19
|
|
|
|
|
|
|
$update_args->{value} ||= []; |
20
|
|
|
|
|
|
|
my $field_values = $self->field_value || []; |
21
|
|
|
|
|
|
|
$update_args->{value} = [ @{ $field_values }, |
22
|
|
|
|
|
|
|
@{ $update_args->{value} } ]; |
23
|
|
|
|
|
|
|
my $rv = SPOPS::SQLInterface->db_update( $update_args ); |
24
|
|
|
|
|
|
|
return ( $rv eq '0E0' ) ? 0 : $rv; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub set_update_data { |
28
|
|
|
|
|
|
|
my ( $self, $update_info ) = @_; |
29
|
|
|
|
|
|
|
my @fields = (); |
30
|
|
|
|
|
|
|
my @values = (); |
31
|
|
|
|
|
|
|
while ( my ( $field, $value ) = each %{ $update_info } ) { |
32
|
|
|
|
|
|
|
push @fields, $field; |
33
|
|
|
|
|
|
|
push @values, $value; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
$self->field( \@fields ); |
36
|
|
|
|
|
|
|
$self->field_value( \@values ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |