[vhffs-dev] [1587] Added a function to fetch a tag category by its label. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1587
Author: guillaumito
Date: 2010-04-07 22:42:04 +0200 (Wed, 07 Apr 2010)
Log Message:
-----------
Added a function to fetch a tag category by its label.
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Tag/Category.pm
Modified: trunk/vhffs-api/src/Vhffs/Tag/Category.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Tag/Category.pm 2010-04-02 22:10:53 UTC (rev 1586)
+++ trunk/vhffs-api/src/Vhffs/Tag/Category.pm 2010-04-07 20:42:04 UTC (rev 1587)
@@ -79,6 +79,23 @@
return $category;
}
+sub get_by_label {
+ my ($main, $label) = @_;
+
+ my $dbh = $main->get_db_object();
+
+ my $sql = q{SELECT tag_category_id, label, description, visibility, updated, updater_id
+ FROM vhffs_tag_category WHERE label = ?};
+
+ my $sth = $dbh->prepare($sql);
+ $sth->execute($label) or return undef;
+ my @results = $sth->fetchrow_array();
+ return undef unless @results;
+
+ my $category = _new Vhffs::Tag::Category($main, @results);
+
+ return $category;
+}
sub get_all {
my ($main, $visibility) = @_;
@@ -152,4 +169,4 @@
return $VISIBILITY_STRING[$visibility_id];
}
-1;
\ No newline at end of file
+1;