From 05f3e3b0fdd8f805e365f56e0690c7478d6f8151 Mon Sep 17 00:00:00 2001 From: janw Date: Wed, 4 Mar 2009 13:35:05 +0000 Subject: [PATCH] 'Repair' count_dbentries function. Use DBsqlite->count_dbentries for count functions (fai_release, fai_server, packages_list). git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13495 594d385d-05f5-0310-b6e9-bd551577e9d8 --- trunk/gosa-si/modules/DBsqlite.pm | 8 +++++--- trunk/gosa-si/server/events/databases.pm | 8 +------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/trunk/gosa-si/modules/DBsqlite.pm b/trunk/gosa-si/modules/DBsqlite.pm index ec94f298e..c9ebc440f 100644 --- a/trunk/gosa-si/modules/DBsqlite.pm +++ b/trunk/gosa-si/modules/DBsqlite.pm @@ -370,12 +370,14 @@ sub exec_statementlist { sub count_dbentries { my ($self, $table)= @_; my $error= 0; - my $answer= -1; + my $count= -1; - my $sql_statement= "SELECT * FROM $table"; + my $sql_statement= "SELECT count() FROM $table"; my $db_answer= &select_dbentry($self, $sql_statement); + if(defined($db_answer) && defined($db_answer->{1}) && defined($db_answer->{1}->{'count()'})) { + $count = $db_answer->{1}->{'count()'}; + } - my $count = keys(%{$db_answer}); return $count; } diff --git a/trunk/gosa-si/server/events/databases.pm b/trunk/gosa-si/server/events/databases.pm index 942dbda06..ac934d53b 100644 --- a/trunk/gosa-si/server/events/databases.pm +++ b/trunk/gosa-si/server/events/databases.pm @@ -106,13 +106,7 @@ sub count_db { $db = $main::fai_release_db; } - - # prepare sql statement and execute query - my $res_hash = $db->select_dbentry("SELECT count() FROM $table"); - my $count = 0; - if(defined($res_hash) && defined($res_hash->{1}) && defined($res_hash->{1}->{'count()'})) { - $count = $res_hash->{1}->{'count()'}; - } + my $count = $db->count_dbentries($table); my $out_xml= "
answer
$target$source$count$session_id
"; my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; if (defined $forward_to_gosa) { -- 2.30.2