Memories::Photo->set_sql(sorted_by_tag => q/
SELECT photo.id as id, title, uploader, uploaded, x, y
-FROM photo, tag, tagging
+FROM photo, tagging
WHERE tagging.photo = photo.id
- AND tagging.tag = tag.id
- AND tag.id = ?
+ AND tagging.tag = ?
ORDER BY photo.uploaded DESC
/
);
$sth->finish;
$r->{template_args}{tags} = \@tags;
} else {
- if (!$r->objects) {
+ if (!@{$r->objects||[]}) {
$tag = $tags[0];
} else {
$tag = $r->objects->[0];
package Memories::Tagging;
use base qw(Memories::DBI);
-use Class::DBI::Pager;
-__PACKAGE__->columns(TEMP => qw/count/);
-__PACKAGE__->columns(Essential => qw/id tag photo/);
-__PACKAGE__->set_sql(summary => qq/
-SELECT id, tag, count(*) AS count
-FROM tagging
-GROUP BY tag
-ORDER BY count DESC
-LIMIT 75
- /);
-__PACKAGE__->set_sql(all => qq/
-SELECT id, tag, count(*) AS count
-FROM tagging
-GROUP BY tag
-ORDER BY count DESC
- /);
+
+
__PACKAGE__->set_sql(user_summary => qq/
SELECT tagging.id id, tag, count(*) AS count
FROM tagging, photo
ORDER BY count DESC
/);
-Memories::Tagging->has_a("photo" => "Memories::Photo");
-Memories::Tagging->has_a("tag" => "Memories::Tag");
-
-Memories::Photo->has_many(tags => ["Memories::Tagging" => "tag"]);
-Memories::Photo->has_many(taggings => "Memories::Tagging");
-Memories::Tag->has_many(photos => ["Memories::Tagging" => "photo"] );
-Memories::Tag->has_many(taggings => "Memories::Tagging");
-
1;