projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
46fb556
)
finish modification
author
ivan
<ivan>
Sat, 11 Dec 2004 23:16:10 +0000
(23:16 +0000)
committer
ivan
<ivan>
Sat, 11 Dec 2004 23:16:10 +0000
(23:16 +0000)
FS/FS/part_export/acct_sql.pm
patch
|
blob
|
history
diff --git
a/FS/FS/part_export/acct_sql.pm
b/FS/FS/part_export/acct_sql.pm
index
dfc37d0
..
fb0299c
100644
(file)
--- a/
FS/FS/part_export/acct_sql.pm
+++ b/
FS/FS/part_export/acct_sql.pm
@@
-107,6
+107,24
@@
sub _export_insert {
}
sub _export_replace {
}
sub _export_replace {
+ my($self, $new, $old) = (shift, shift, shift);
+
+ my %map = $self->_map;
+ my $keymap = $map{$self->option('primary_key')};
+
+ my %record = map { my $value = $map{$_};
+ $_ => $new->$value();
+ } keys %map;
+
+ my $err_or_queue = $self->acct_sql_queue(
+ $new->svcnum,
+ 'replace',
+ $self->option('table'),
+ $self->option('primary_key') => $old->$keymap(),
+ %record,
+ );
+ return $err_or_queue unless ref($err_or_queue);
+ '';
}
sub _export_delete {
}
sub _export_delete {
@@
-146,7
+164,7
@@
sub acct_sql_insert { #subroutine, not method
" ) VALUES ( ". join(", ", map '?', keys %record ). " )"
) or die $dbh->errstr;
" ) VALUES ( ". join(", ", map '?', keys %record ). " )"
) or die $dbh->errstr;
- $sth->execute(
map $record{$_}, keys %record
)
+ $sth->execute(
values(%record)
)
or die "can't insert into $table table: ". $sth->errstr;
$dbh->disconnect;
or die "can't insert into $table table: ". $sth->errstr;
$dbh->disconnect;
@@
-157,7
+175,7
@@
sub acct_sql_delete { #subroutine, not method
my( $table, %record ) = @_;
my $sth = $dbh->prepare(
my( $table, %record ) = @_;
my $sth = $dbh->prepare(
- "DELETE FROM
$table WHERE ". join(' AND ', map "$_ = ? ", keys %record )
+ "DELETE FROM $table WHERE ". join(' AND ', map "$_ = ? ", keys %record )
) or die $dbh->errstr;
$sth->execute( map $record{$_}, keys %record )
) or die $dbh->errstr;
$sth->execute( map $record{$_}, keys %record )
@@
-166,6
+184,20
@@
sub acct_sql_delete { #subroutine, not method
$dbh->disconnect;
}
$dbh->disconnect;
}
+sub acct_sql_replace { #subroutine, not method
+ my $dbh = acct_sql_connect(shift, shift, shift);
+ my( $table, $pkey, $old_pkey, %record ) = @_;
+
+ my $sth = $dbh->prepare(
+ "UPDATE $table SET ". join(', ', map "$_ = ?", keys %record ).
+ "WHERE $pkey = ?"
+ ) or die $dbh->errstr;
+
+ $sth->execute( values(%record), $old_pkey );
+
+ $dbh->disconnect;
+}
+
sub acct_sql_connect {
#my($datasrc, $username, $password) = @_;
#DBI->connect($datasrc, $username, $password) or die $DBI::errstr;
sub acct_sql_connect {
#my($datasrc, $username, $password) = @_;
#DBI->connect($datasrc, $username, $password) or die $DBI::errstr;
@@
-174,4
+206,3
@@
sub acct_sql_connect {
1;
1;
-