freeside/FS/FS/part_export acct_sql.pm,1.6,1.7

ivan ivan at pouncequick.420.am
Sat Dec 11 15:16:13 PST 2004


Update of /home/cvs/cvsroot/freeside/FS/FS/part_export
In directory pouncequick:/tmp/cvs-serv27779

Modified Files:
	acct_sql.pm 
Log Message:
finish modification

Index: acct_sql.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_export/acct_sql.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- acct_sql.pm	26 May 2004 13:07:47 -0000	1.6
+++ acct_sql.pm	11 Dec 2004 23:16:10 -0000	1.7
@@ -107,6 +107,24 @@
 }
 
 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 {
@@ -146,7 +164,7 @@
     " ) 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;
@@ -157,7 +175,7 @@
   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 )
@@ -166,6 +184,20 @@
   $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;
@@ -173,5 +205,4 @@
 }
 
 1;
-
 




More information about the freeside-commits mailing list