1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
10 #======================================================================
16 $main::lxdebug->enter_sub();
18 my ($self, $myconfig, $form) = @_;
20 my $dbh = $form->dbconnect($myconfig);
21 my $query = qq|SELECT f.line
23 WHERE f.file = '$form->{file}'
24 AND f.dbname = '$myconfig->{dbname}'
26 my $sth = $dbh->prepare($query);
27 $sth->execute || $form->dberror($query);
31 while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
32 push @{ $form->{body} }, $ref->{line};
39 $main::lxdebug->leave_sub();
45 $main::lxdebug->enter_sub();
47 my ($self, $myconfig, $form) = @_;
49 # connect to database, turn AutoCommit off
50 my $dbh = $form->dbconnect_noauto($myconfig);
52 my $query = qq|DELETE FROM xiii_forms
53 WHERE file = '$form->{file}'
54 AND dbname = '$myconfig->{dbname}'|;
55 $dbh->do($query) || $form->dberror($query);
61 $main::lxdebug->leave_sub();
68 $main::lxdebug->enter_sub();
70 my ($self, $myconfig, $form) = @_;
72 # connect to database, turn AutoCommit off
73 my $dbh = $form->dbconnect_noauto($myconfig);
75 my $query = qq|DELETE FROM xiii_forms
76 WHERE file = '$form->{file}'
77 AND dbname = '$myconfig->{dbname}'|;
78 $dbh->do($query) || $form->dberror($query);
81 $query = qq|INSERT INTO xiii_forms (line, file, dbname)
82 VALUES (?, '$form->{file}', '$myconfig->{dbname}')|;
84 $sth = $dbh->prepare($query);
87 foreach $line (split /\r/, $form->{body}) {
88 $sth->execute($line) || $form->dberror($query);
95 $main::lxdebug->leave_sub();