summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-09-24 01:40:57 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-09-24 01:40:57 +0000
commit79b9272f11148755c0da2cd158738b32257fdfb3 (patch)
tree5c73048941d004f0628ece49d84e32e551136ffc
parent5cf7df87f87c8333dd6deab69af218e37970bc94 (diff)
Fixed version for now.
Added an API to the Form object for creating SELECT, INSERT, and UPDATE queries based on custom fields git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@137 4979c152-3d1c-0410-bac9-87ea11338e46
-rwxr-xr-xLedgerSMB/Form.pm48
-rw-r--r--VERSION2
2 files changed, 43 insertions, 7 deletions
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm
index 6bca3ddd..7a578448 100755
--- a/LedgerSMB/Form.pm
+++ b/LedgerSMB/Form.pm
@@ -62,7 +62,7 @@ sub new {
$self->{menubar} = 1 if $self->{path} =~ /lynx/i;
- $self->{version} = "1.1.0";
+ $self->{version} = "1.1.1";
$self->{dbversion} = "2.6.18";
bless $self, $type;
@@ -1281,31 +1281,67 @@ sub db_init {
}
sub get_custom_queries {
- my ($self, $tablename) = @_;
+ my ($self, $tablename, $query_type, $linenum) = @_;
+ if ($query_type !~ /^(select|insert|update)$/i){
+ $self->error($locale->text(
+ "Passed incorrect query type to get_cutstom_queries."
+ ));
+ }
my @rc;
my %temphash;
+ my @templist;
my @elements;
my $query;
+ my $ins_values;
+ if ($linenum){
+ $linenum = "_$linenum";
+ }
+
+ $query_type = uc($query_type);
for (@{$self->{custom_db_fields}{$tablename}}){
@elements = split (/:/, $_);
push @{$temphash{$elements[0]}}, $elements[1];
}
for (keys %temphash){
- $query = "SELECT ";
+ my @data;
+ $query = "$query_type ";
+ if ($query_type eq 'UPDATE'){
+ $query .= " $_ SET ";
+ } elsif ($query_type eq 'INSERT'){
+ $query .= " INTO $_ (";
+ }
my $first = 1;
for (@{$temphash{$_}}){
$query .= "$_";
+ if ($query_type eq 'UPDATE'){
+ $query .= '= ?';
+ }
+ my $ins_values .= "?, ";
if ($first == 0){
- $query .= ", "
+ $query .= ", ";
}
$first = 0;
+ if ($query_type eq 'UPDATE' or $query_type eq 'INERT'){
+ push @data, $form->{$_ . $linenum};
+ }
+ }
+ if ($query_type eq 'SELECT'){
+ $query .= " FROM $_";
+ }
+ if ($query_type eq 'SELECT' or $query_type eq 'UPDATE'){
+ $query .= " WHERE field_id = ?";
+ }
+ if ($query_type eq 'SELECT'){
+ push @rc, [ $query ];
+ } else {
+ unshift (@data, $query);
+ push @rc, [ @data ];
}
- $query .= " FROM $_ WHERE field_id = ?";
- push @rc, $query;
}
@rc;
}
+
sub dbconnect {
my ($self, $myconfig) = @_;
diff --git a/VERSION b/VERSION
index 9084fa2f..524cb552 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.1.0
+1.1.1