[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [164] trunk/LedgerSMB
- Subject: SF.net SVN: ledger-smb: [164] trunk/LedgerSMB
- From: ..hidden..
- Date: Fri, 29 Sep 2006 10:23:25 -0700
Revision: 164
http://svn.sourceforge.net/ledger-smb/?rev=164&view=rev
Author: einhverfr
Date: 2006-09-29 10:23:22 -0700 (Fri, 29 Sep 2006)
Log Message:
-----------
Simplified custom fields API.
Modified Paths:
--------------
trunk/LedgerSMB/Form.pm
trunk/LedgerSMB/IS.pm
trunk/LedgerSMB/OE.pm
Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm 2006-09-28 15:35:08 UTC (rev 163)
+++ trunk/LedgerSMB/Form.pm 2006-09-29 17:23:22 UTC (rev 164)
@@ -1282,6 +1282,7 @@
}
sub get_custom_queries {
+ my $dbh = $self->{dbh};
my ($self, $tablename, $query_type, $linenum) = @_;
if ($query_type !~ /^(select|insert|update)$/i){
$self->error($locale->text(
@@ -1308,7 +1309,10 @@
my $ins_values;
$query = "$query_type ";
if ($query_type eq 'UPDATE'){
- $query .= " $_ SET ";
+ $query = "DELETE FROM $_ WHERE row_id = ?";
+ my $sth = $dbh->prepare($query);
+ $sth->execute->($form->{"id"."$linenum"})
+ || $self->dberror($query);
} elsif ($query_type eq 'INSERT'){
$query .= " INTO $_ (";
}
@@ -1344,6 +1348,30 @@
push @rc, [ @data ];
}
}
+ if ($query_type eq 'INSERT'){
+ for (@rc){
+ $query = shift (@{$_});
+ $sth = $dbh->prepare($query)
+ || $form->db_error($query);
+ $sth->execute(@{$_}, $form->{id})
+ || $form->dberror($query);;
+ $sth->finish;
+ $did_insert = 1;
+ }
+ } elsif ($query_type eq 'UPDATE'){
+ @rc = $self->get_custom_queries(
+ $tablename, $query_type, $linenum);
+ } elsif ($query_type eq 'SELECT'){
+ for (@rc){
+ $query = shift @{$_};
+ $sth = $form->{dbh}->prepare($query);
+ $sth->execute($form->{id});
+ $ref = $sth->fetchrow_hashref(NAME_lc);
+ for (keys %{$ref}){
+ $form->{$_} = $ref->{$_};
+ }
+ }
+ }
@rc;
}
Modified: trunk/LedgerSMB/IS.pm
===================================================================
--- trunk/LedgerSMB/IS.pm 2006-09-28 15:35:08 UTC (rev 163)
+++ trunk/LedgerSMB/IS.pm 2006-09-29 17:23:22 UTC (rev 164)
@@ -635,13 +635,6 @@
$sth->finish;
@queries = $form->get_custom_queries('ar', 'INSERT');
- for (@queries){
- $query = shift (@{$_});
- $sth = $dbh->prepare($query) || $form->db_error($query);
- $sth->execute(@{$_}, $form->{id})|| $form->dberror($query);;
- $sth->finish;
- $did_insert = 1;
- }
}
@@ -1431,15 +1424,6 @@
$dbh->disconnect;
@queries = $form->get_custom_queries('ar', 'SELECT');
- for (@queries){
- $query = shift @{$_};
- $sth = $form->{dbh}->prepare($query);
- $sth->execute($form->{id});
- $ref = $sth->fetchrow_hashref(NAME_lc);
- for (keys %{$ref}){
- $form->{$_} = $ref->{$_};
- }
- }
$form->{dbh}->commit;
$rc;
Modified: trunk/LedgerSMB/OE.pm
===================================================================
--- trunk/LedgerSMB/OE.pm 2006-09-28 15:35:08 UTC (rev 163)
+++ trunk/LedgerSMB/OE.pm 2006-09-29 17:23:22 UTC (rev 164)
@@ -362,15 +362,6 @@
@queries = $form->get_custom_queries('oe', 'INSERT');
- for (@queries){
- $query = shift (@{$_});
- $sth = $dbh->prepare($query)
- || $form->db_error($query);
- $sth->execute(@{$_}, $form->{id})
- || $form->dberror($query);;
- $sth->finish;
- $did_insert = 1;
- }
}
my $amount;
@@ -632,12 +623,6 @@
if (!$did_insert){
@queries = $form->get_custom_queries('oe', 'UPDATE');
- for (@queries){
- my $query = shift @{$_};
- $sth = $dbh->prepare($query);
- $sth->execute (@{$_}, $form->{id});
- $sth->finish;
- }
}
@@ -958,15 +943,6 @@
$form->get_recurring($dbh);
@queries = $form->get_custom_queries('oe', 'SELECT');
- for (@queries){
- $query = shift @{$_};
- $sth = $form->{dbh}->prepare($query);
- $sth->execute($form->{id});
- $ref = $sth->fetchrow_hashref(NAME_lc);
- for (keys %{$ref}){
- $form->{$_} = $ref->{$_};
- }
- }
$form->{dbh}->commit;
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.