Code

'Repair' count_dbentries function.
authorjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 4 Mar 2009 13:35:05 +0000 (13:35 +0000)
committerjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 4 Mar 2009 13:35:05 +0000 (13:35 +0000)
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
trunk/gosa-si/server/events/databases.pm

index ec94f298e64eb2a317b3b0a428982a1d136e1e79..c9ebc440f562bc4d91405895236e40f4125f6e9c 100644 (file)
@@ -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;
 }
 
index 942dbda065d886662a2756f5be18f5f7795c7268..ac934d53bde4e33c9e5280ccb719eedf0b8d10ae 100644 (file)
@@ -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= "<xml><header>answer</header><source>$target</source><target>$source</target><count>$count</count><session_id>$session_id</session_id></xml>";
     my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
     if (defined $forward_to_gosa) {