Code

Changed wrong function name.
authorjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 4 Mar 2009 12:52:36 +0000 (12:52 +0000)
committerjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 4 Mar 2009 12:52:36 +0000 (12:52 +0000)
Use SQL Count()-Function to improve performance.

git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13493 594d385d-05f5-0310-b6e9-bd551577e9d8

trunk/gosa-si/server/events/databases.pm

index 6870505827e081406b744f3d1cb27a6f5002de92..942dbda065d886662a2756f5be18f5f7795c7268 100644 (file)
@@ -80,7 +80,7 @@ sub query_db {
     return @out_msg_l;
 }
     
-sub count_fai_releas{ return &count_db( @_ ); }    
+sub count_fai_release{ return &count_db( @_ ); }    
 sub count_fai_server{ return &count_db( @_ ); }
 sub count_packages_list{ return &count_db( @_ ); }
 sub count_jobdb{ return &count_db( @_ ); }
@@ -103,14 +103,16 @@ sub count_db {
         $db = $main::fai_server_db;
     } elsif( $header =~ /count_fai_release/ ) {
         $table = $main::fai_release_tn;
-        $db = $main::fai_server_db;
+        $db = $main::fai_release_db;
     }
 
 
     # prepare sql statement and execute query
-    my $res_hash = $db->select_dbentry("SELECT * FROM $table");
-
-    my $count = keys(%{$res_hash});
+               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 $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) {