1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
10 #======================================================================
15 $main::lxdebug->enter_sub();
17 my ($self, $myconfig, $form) = @_;
19 my $dbh = $form->dbconnect($myconfig);
20 my $query = qq|SELECT f.line
22 WHERE f.file = '$form->{file}'
23 AND f.dbname = '$myconfig->{dbname}'
25 my $sth = $dbh->prepare($query);
26 $sth->execute || $form->dberror($query);
30 while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
31 push @{ $form->{body} }, $ref->{line};
38 $main::lxdebug->leave_sub();
42 $main::lxdebug->enter_sub();
44 my ($self, $myconfig, $form) = @_;
46 # connect to database, turn AutoCommit off
47 my $dbh = $form->dbconnect_noauto($myconfig);
49 my $query = qq|DELETE FROM xiii_forms
50 WHERE file = '$form->{file}'
51 AND dbname = '$myconfig->{dbname}'|;
52 $dbh->do($query) || $form->dberror($query);
58 $main::lxdebug->leave_sub();
64 $main::lxdebug->enter_sub();
66 my ($self, $myconfig, $form) = @_;
68 # connect to database, turn AutoCommit off
69 my $dbh = $form->dbconnect_noauto($myconfig);
71 my $query = qq|DELETE FROM xiii_forms
72 WHERE file = '$form->{file}'
73 AND dbname = '$myconfig->{dbname}'|;
74 $dbh->do($query) || $form->dberror($query);
76 $query = qq|INSERT INTO xiii_forms (line, file, dbname)
77 VALUES (?, '$form->{file}', '$myconfig->{dbname}')|;
79 $sth = $dbh->prepare($query);
81 foreach $line (split /\r/, $form->{body}) {
82 $sth->execute($line) || $form->dberror($query);
89 $main::lxdebug->leave_sub();