-sub tags_subselect_or
-{
- my($self,@constraints)=@_;
- my ($tags, $tags_vals, $parent)=$self->constraints_tag_list(@constraints);
- my @tags=@$tags;
- my @tags_vals=@$tags_vals;;
-
- my $sql=("\tSELECT files_x_tags.files_id FROM tags t1\n" .
- "\tINNER JOIN files_x_tags ON t1.id=files_x_tags.tags_id\n");
- my @orclauses=();
- my @andclauses=();
- # FIXME: and / or?
- if(@tags)
- {
- push(@andclauses, "( t1.parents_id=" . (defined($parent) ? $parent : "''") . " )");
- push(@andclauses, "( t1.id IN ( " . join(', ', @tags) ." ) )");
- }
- for my $pair (@tags_vals)
- {
- my($tag, $val)=@$pair;
- push(@orclauses, "( t1.parents_id=$tag AND t1.id=$val )");
- }
-# push(@andclauses, "( t1.parents_id=" . (defined($parent) ? $parent : "''") . " )");
- if(@orclauses)
- {
- push(@andclauses, join("\n\t\tOR ", @orclauses));
- }
- if(@andclauses)
- {
- $sql .= "\tWHERE\n\t\t";
- $sql .= join("\n\t\tAND ", @andclauses) . "\n";
- }
- $sql .= "\tGROUP BY files_x_tags.files_id\n";
- return $sql;
-}