Advanced Search in web DBIx::Class based applications (with tags, full text search and searching by location) is an update to Tags and search and DBIx::Class.
I think it is a nice technique.
Sunday, December 16, 2007
Subscribe to:
Post Comments (Atom)
1 comment:
Well my vision about tags is very simple and is usable for small entries, I consider you have a tag field of this sort :
Tags, varchar (100)
For your DBIx::Class Scheme is like this :
__PACKAGE__->load_components(qw/InflateColumn::DateTime PK::Auto Core/);
__PACKAGE__->inflate_column(
Tags =>
{
inflate => sub {
my ($value, $obj) = @_;
my @tags = split(/ /, $value);
return \@tags;
},
}
);
In your controller file you may use this :
$c->stash->{tagsList}=[$c->model('YourMODEL')->resultset('tableName')->tags()];
For search I use :
my $where = "( ";
for my $tag ( @paramTags ) {
$tagsDisplayed{$tag}=1;
$where .= "Tags LIKE '%$tag%' AND "
}
$where =~ s/\sAND\s$/ \) AND \(/;
@result = $c->model('Model:tableName')->search({}, { where => $where });
that's all
Post a Comment