Here are a few Totals globals that I have gathered together from these forums. May be useful all in one place.
my ($total) = $DB->table('Links')->select(['SUM(Hits)'])->fetchrow_array;
return $total;
}
------------------------------------------
sub { # show total number of hits (with commas - 123,456)
local $_ = $DB->table('Links')->select(['SUM(Hits)'])->fetchrow_array;
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
------------------------------------------
sub { # show total number of votes (without commas - 123456)
my ($total) = $DB->table('Links')->select(['SUM(Votes)'])->fetchrow_array;
return $total;
}
------------------------------------------
sub { # show total number of votes (with commas - 123,456)
local $_ = $DB->table('Links')->select(['SUM(Votes)'])->fetchrow_array;
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
------------------------------------------
sub { # show grand total (with commas - 123,456)
my $tags = shift;
local $_ = $tags->{grand_total};
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
TAG: Replace <%grand_total%> with <%grand_total_formatted%>
------------------------------------------
sub { # show total number of categories (without commas - 123456)
my $cat_db = $DB->table ('Category');
my $count = $cat_db->total;
return $count;
}
------------------------------------------
sub { # show total number of reviews (without commas - 123456)
my $cat_db = $DB->table ('Reviews');
my $count = $cat_db->total;
return $count;
}
------------------------------------------
sub { # show total number of new links (without commas - 123456)
$DB->table('Links')->count({isNew => 'Yes'})
}
------------------------------------------
sub { # show total number of updated links (without commas - 123456)
$DB->table('Links')->count({isChanged => 'Yes'})
}
------------------------------------------
If you have any more please add them.
Code:
sub { # show total number of hits (without commas - 123456) my ($total) = $DB->table('Links')->select(['SUM(Hits)'])->fetchrow_array;
return $total;
}
------------------------------------------
sub { # show total number of hits (with commas - 123,456)
local $_ = $DB->table('Links')->select(['SUM(Hits)'])->fetchrow_array;
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
------------------------------------------
sub { # show total number of votes (without commas - 123456)
my ($total) = $DB->table('Links')->select(['SUM(Votes)'])->fetchrow_array;
return $total;
}
------------------------------------------
sub { # show total number of votes (with commas - 123,456)
local $_ = $DB->table('Links')->select(['SUM(Votes)'])->fetchrow_array;
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
------------------------------------------
sub { # show grand total (with commas - 123,456)
my $tags = shift;
local $_ = $tags->{grand_total};
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
TAG: Replace <%grand_total%> with <%grand_total_formatted%>
------------------------------------------
sub { # show total number of categories (without commas - 123456)
my $cat_db = $DB->table ('Category');
my $count = $cat_db->total;
return $count;
}
------------------------------------------
sub { # show total number of reviews (without commas - 123456)
my $cat_db = $DB->table ('Reviews');
my $count = $cat_db->total;
return $count;
}
------------------------------------------
sub { # show total number of new links (without commas - 123456)
$DB->table('Links')->count({isNew => 'Yes'})
}
------------------------------------------
sub { # show total number of updated links (without commas - 123456)
$DB->table('Links')->count({isChanged => 'Yes'})
}
------------------------------------------
If you have any more please add them.