[Cpan-forum-commit] rev 254 - in trunk: . lib/CPAN/Forum/DB
svn at pti.co.il
svn at pti.co.il
Thu Jul 19 17:04:25 EEST 2007
Author: gabor
Date: 2007-07-19 17:04:25 +0300 (Thu, 19 Jul 2007)
New Revision: 254
Modified:
trunk/
trunk/lib/CPAN/Forum/DB/Tags.pm
Log:
some SQL cleanup, calling common methods instead of implementing alorithm locally
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4196
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752
+ 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4221
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752
Modified: trunk/lib/CPAN/Forum/DB/Tags.pm
===================================================================
--- trunk/lib/CPAN/Forum/DB/Tags.pm 2007-07-19 05:50:30 UTC (rev 253)
+++ trunk/lib/CPAN/Forum/DB/Tags.pm 2007-07-19 14:04:25 UTC (rev 254)
@@ -2,8 +2,7 @@
use strict;
use warnings;
-use CPAN::Forum::DBI;
-
+use base 'CPAN::Forum::DBI';
use Carp qw();
sub get_tags_hash_of {
@@ -91,28 +90,16 @@
sub _get_tag_id {
my ($self, $text) = @_;
- my $dbh = CPAN::Forum::DBI::db_Main();
- my $sth = $dbh->prepare("SELECT id FROM tags WHERE name=?");
- $sth->execute($text);
- my ($id) = $sth->fetchrow_array;
- $sth->finish;
- return $id;
+ return $self->_fetch_single_value("SELECT id FROM tags WHERE name=?", $text);
}
sub get_all_tags {
my ($self) = @_;
- my $dbh = CPAN::Forum::DBI::db_Main();
my $sql = "SELECT name
- FROM tags
+ FROM tags
WHERE id IN (SELECT DISTINCT tag_id FROM tag_cloud) ORDER BY name ASC";
- my $sth = $dbh->prepare($sql);
- $sth->execute;
- my @tags;
- while (my $hr = $sth->fetchrow_hashref) {
- push @tags, $hr;
- }
- return \@tags;
+ return $self->_fetch_arrayref_of_hashes($sql);
}
sub get_modules_with_tag {
@@ -122,14 +109,7 @@
FROM groups, tags, tag_cloud
WHERE groups.id=tag_cloud.group_id AND tag_cloud.tag_id=tags.id AND tags.name=?
GROUP BY groups.name";
- my $dbh = CPAN::Forum::DBI::db_Main();
- my $sth = $dbh->prepare($sql);
- $sth->execute($tag_name);
- my @res;
- while (my $hr = $sth->fetchrow_hashref) {
- push @res, $hr;
- }
- return \@res;
+ return $self->_fetch_arrayref_of_hashes($sql, $tag_name);
}
More information about the Cpan-forum-commit
mailing list