From 59477ddf266ae5c48c4dcff3466b775aa1b6a215 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Sat, 31 Jan 2004 16:18:42 +0000 Subject: [PATCH] Use abstract search instead; more flexible. git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@35 48953598-375a-da11-a14b-00016c27c3ee --- lib/Apache/MVC/Model/CDBI.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Apache/MVC/Model/CDBI.pm b/lib/Apache/MVC/Model/CDBI.pm index 88c1d52..4d6339d 100644 --- a/lib/Apache/MVC/Model/CDBI.pm +++ b/lib/Apache/MVC/Model/CDBI.pm @@ -3,6 +3,7 @@ use base qw(Apache::MVC::Model::Base Class::DBI); use Lingua::EN::Inflect::Number qw(to_PL); use Class::DBI::AsForm; use Class::DBI::FromCGI; +use Class::DBI::AbstractSearch; use CGI::Untaint; use strict; @@ -63,9 +64,13 @@ sub adopt { sub search :Exported { my ($self, $r) = @_; my %fields = map {$_ => 1 } $self->columns; - my %values = map { $_ => $params{$_} } - grep { $params{$_} and $fields{$_} } keys %{$r->{params}}; - $r->objects([ %values ? $self->search_like(%values) : $self->retrieve_all ]); + my $oper = "like"; # For now + my %params = %{$r->{params}}; + my %values = map { $_ => {$oper, $oper eq "like" ? "%".$params{$_}."%" + :$params{$_} } } + grep { $params{$_} and $fields{$_} } keys %params; + + $r->objects([ %values ? $self->search_where(%values) : $self->retrieve_all ]); $r->template("list"); $r->{template_args}{search} = 1; } -- 2.39.5