From e7c0716a6749741164bc345dc59f8636022695a4 Mon Sep 17 00:00:00 2001 From: "Difrex(Denis Zheleztsov)" Date: Tue, 12 Aug 2014 11:46:13 +0400 Subject: [PATCH] Search is working. But it is case sensitive --- II/DB.pm | 12 +++++------- iiplc.app | 4 +++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/II/DB.pm b/II/DB.pm index 74ecb45..6da6ed0 100644 --- a/II/DB.pm +++ b/II/DB.pm @@ -2,7 +2,6 @@ package II::DB; use SQL::Abstract; use DBI; -use Encode; use utf8; use Data::Dumper; @@ -340,13 +339,12 @@ sub do_search { my ( $self, $query ) = @_; my $dbh = $self->{_dbh}; - # $query = $query; - - print "QUERY " . $query . "\n"; - - my $q - = "select from_user, to_user, subg, time, echo, post, hash from messages where subg like '\%$query\%' order by time"; + my $q = "select from_user, to_user, subg, time, echo, post, hash + from messages where subg + like '\%$query\%' COLLATE NOCASE + order by time"; + print "SQL: " . $q . "\n"; my $sth = $dbh->prepare($q); $sth->execute(); diff --git a/iiplc.app b/iiplc.app index 2b1a8ea..6b93116 100644 --- a/iiplc.app +++ b/iiplc.app @@ -186,7 +186,9 @@ my $search = sub { my $query = $req->param('q'); my $db = II::DB->new(); - my $result = $db->do_search($q); + my @post = $db->do_search($query); + + my $result = $render->search(@post); return [ 200, [ 'Content-type' => 'text/html' ], [$result], ]; };