From 137cc176814f2e5d3750309b3bfe2072e14ee373 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Tue, 19 Feb 2008 08:50:45 +0000 Subject: [PATCH] bugfix in create_table git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8947 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/modules/DBsqlite.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gosa-si/modules/DBsqlite.pm b/gosa-si/modules/DBsqlite.pm index 95ac1b68b..bce1e620c 100644 --- a/gosa-si/modules/DBsqlite.pm +++ b/gosa-si/modules/DBsqlite.pm @@ -71,8 +71,15 @@ sub create_table { my $self = shift; my $table_name = shift; my $col_names_ref = shift; + my @col_names; + foreach my $col_name (@$col_names_ref) { + my @t = split(" ", $col_name); + $col_name = $t[0]; + push(@col_names, $col_name); + } + $col_names->{ $table_name } = $col_names_ref; - my $col_names_string = join(', ', @{$col_names_ref}); + my $col_names_string = join(', ', @col_names); my $sql_statement = "CREATE TABLE IF NOT EXISTS $table_name ( $col_names_string )"; &create_lock($self,'create_table'); $self->{dbh}->do($sql_statement); @@ -126,19 +133,19 @@ sub add_dbentry { # primekey is unique # fetch column names of table - my $col_names = &get_table_columns("",$table); + my $col_names = &get_table_columns($self, $table); # assign values to column name variables my @add_list; foreach my $col_name (@{$col_names}) { - # use function parameter for column values + # use function parameter for column values + if (exists $arg->{$col_name}) { push(@add_list, $arg->{$col_name}); } } my $sql_statement = "INSERT INTO $table VALUES ('".join("', '", @add_list)."')"; - &create_lock($self,'add_dbentry'); my $db_res = $self->{dbh}->do($sql_statement); &remove_lock($self,'add_dbentry'); @@ -192,6 +199,7 @@ sub get_table_columns { &create_lock($self,'get_table_columns'); my @res = @{$self->{dbh}->selectall_arrayref("pragma table_info('$table')")}; &remove_lock($self,'get_table_columns'); + foreach my $column (@res) { push(@column_names, @$column[1]); } -- 2.30.2