@textquery = ();
$text =~ s/[^\w\d\s\-]//g;
@words = split /\s+/, $text;
foreach my $word (@words) {
push @textquery, 'search_text LIKE ?';
push @data, '%' . $word . '%';
}
####
UPDATE table SET search_text = CONCAT_WS(' ', name, headline, caption);
####
$text =~ s/[^\w\d\s'"\-]//g;
@words = parse_line('\s+', 1, $text);
####
unless (@words) {
@words = split /\s+/, $text;
}
####
SELECT x, y, z FROM table WHERE x REGEXP '[[:<:]]word[[:>]]'
####
SELECT x, y, z FROM table WHERE x LIKE '%word%' AND x REGEXP '[[:<:]]word[[:>]]'
####
foreach my $word (@words) {
if ($word =~ s/^(["'])(.+)\1$/$2/) {
push @textquery, 'srch_text LIKE ? AND srch_text REGEXP ? ';
push @data, '%' . $word . '%';
push @data, '[[:<:]]' . $word . '[[:>:]]';
} else {
push @textquery, 'srch_text LIKE ?';
push @data, '%' . $word . '%';
}
}