Search is working. But it is case sensitive

This commit is contained in:
Difrex(Denis Zheleztsov) 2014-08-12 11:46:13 +04:00
parent 1235bfe0de
commit e7c0716a67
2 changed files with 8 additions and 8 deletions

View File

@ -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();

View File

@ -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], ];
};