From 6afcba256ded1b4d2978d694fcc4d774f044c08b Mon Sep 17 00:00:00 2001 From: rettenbe Date: Mon, 7 Apr 2008 10:02:46 +0000 Subject: [PATCH] Closes #391 git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10227 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/modules/DBsqlite.pm | 29 ++++++++++++++++++++-------- gosa-si/modules/GosaSupportDaemon.pm | 3 ++- gosa-si/tests/client.php | 1 + 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/gosa-si/modules/DBsqlite.pm b/gosa-si/modules/DBsqlite.pm index aef43265d..0264a9011 100644 --- a/gosa-si/modules/DBsqlite.pm +++ b/gosa-si/modules/DBsqlite.pm @@ -177,22 +177,35 @@ sub select_dbentry { my ($self, $sql)= @_; my $error= 0; my $answer= {}; - my $db_answer= &exec_statement($self, $sql); + my @column_list; # fetch column list of db and create a hash with column_name->column_value of the select query - $sql =~ /FROM ([\S]*?)( |$)/g; - my $table = $1; - my $column_list = &get_table_columns($self, $table); - my $list_len = @{ $column_list } ; + $sql =~ /SELECT ([\S\s]*?) FROM ([\S]*?)( |$)/g; + my $selected_cols = $1; + my $table = $2; + + # all columns are used for creating answer + if ($selected_cols eq '*') { + @column_list = @{ &get_table_columns($self, $table) }; + + # specific columns are used for creating answer + } else { + # remove all blanks and split string to list of column names + $selected_cols =~ s/ //g; + @column_list = split(/,/, $selected_cols); + } + + # create answer my $hit_counter = 0; - foreach my $hit ( @{ $db_answer }) { + my $list_len = @column_list; + foreach my $hit ( @{$db_answer} ){ $hit_counter++; for ( my $i = 0; $i < $list_len; $i++) { - $answer->{ $hit_counter }->{ @{ $column_list }[$i] } = @{ $hit }[$i]; + $answer->{ $hit_counter }->{ $column_list[$i] } = @{ $hit }[$i]; } } - + return $answer; } diff --git a/gosa-si/modules/GosaSupportDaemon.pm b/gosa-si/modules/GosaSupportDaemon.pm index fe027fe17..bd929597b 100644 --- a/gosa-si/modules/GosaSupportDaemon.pm +++ b/gosa-si/modules/GosaSupportDaemon.pm @@ -28,6 +28,7 @@ use Crypt::Rijndael; use Digest::MD5 qw(md5 md5_hex md5_base64); use MIME::Base64; use XML::Simple; +use Data::Dumper; my $op_hash = { 'eq' => '=', @@ -283,7 +284,7 @@ sub get_select_statement { my $select = "*"; if( exists $msg_hash->{'select'} ) { my $select_l = \@{$msg_hash->{'select'}}; - $select = join(' AND ', @{$select_l}); + $select = join(', ', @{$select_l}); } return $select; } diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index 07b6af72c..4fa3eb402 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -85,6 +85,7 @@ if($sock->connected()){ + $sock->write($data); $answer = "nothing"; $answer = $sock->read(); -- 2.30.2