23f30e8259
git-svn-id: http://yolanda.mister-muffin.de/svn@177 7eef14d0-6ed0-489d-bf55-20463b2d70db
32 lines
691 B
Perl
Executable file
32 lines
691 B
Perl
Executable file
#!/usr/bin/perl -w
|
|
|
|
use DBI;
|
|
|
|
$database = 'yolanda';
|
|
$dbhost = 'localhost';
|
|
$dbuser = 'root';
|
|
$dbpass = '';
|
|
|
|
$dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass);
|
|
|
|
$sth = $dbh->prepare("select subject from videos");
|
|
$sth->execute();
|
|
while(($subject) = $sth->fetchrow_array())
|
|
{
|
|
@subject = split(',', $subject);
|
|
foreach my $val (@subject)
|
|
{
|
|
$val =~ s/^\s*(.*?)\s*$/$1/;
|
|
%hash->{$val}++;
|
|
}
|
|
}
|
|
$sth->finish();
|
|
|
|
@sorted = sort {$hash{$b} cmp $hash{$a}} keys %hash;
|
|
|
|
$dbh->do("delete from tagcloud");
|
|
$sth = $dbh->prepare("insert into tagcloud (text, count) values (?, ?)");
|
|
for($i=0;$i<20 and $i<=$#sorted;$i++)
|
|
{
|
|
$sth->execute( $sorted[$i], %hash->{$sorted[$i]} );
|
|
}
|