Skip to content

Commit

Permalink
MDL-24080 converting remaining NOT LIKEs
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Sep 4, 2010
1 parent 2225fb4 commit 4758639
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 22 deletions.
4 changes: 2 additions & 2 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function build_mnet_logs_array($hostid, $course, $user=0, $date=0, $order="l.tim
if ($modaction) {
$firstletter = substr($modaction, 0, 1);
if ($firstletter == '-') {
$where .= " AND l.action NOT LIKE :modaction"; //TODO: MDL-24080
$where .= " AND ".$DB->sql_like('l.action', ':modaction', false, true, true);
$params['modaction'] = '%'.substr($modaction, 1).'%';
} else {
$where .= " AND ".$DB->sql_like('l.action', ':modaction', false);
Expand Down Expand Up @@ -266,7 +266,7 @@ function build_logs_array($course, $user=0, $date=0, $order="l.time ASC", $limit
if ($modaction) {
$firstletter = substr($modaction, 0, 1);
if ($firstletter == '-') {
$joins[] = "l.action NOT LIKE :modaction"; //TODO: MDL-24080
$joins[] = $DB->sql_like('l.action', ':modaction', false, true, true);
$params['modaction'] = '%'.substr($modaction, 1).'%';
} else {
$joins[] = $DB->sql_like('l.action', ':modaction', false);
Expand Down
6 changes: 1 addition & 5 deletions lib/datalib.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,11 +752,7 @@ function get_courses_search($searchterms, $sort='fullname ASC', $page=0, $record
$params['ss'.$i] = "(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)";

} else {
if ($NOT) {
$searchcond[] = "$concat NOT LIKE :ss$i"; //TODO: MDL-24080
} else {
$searchcond[] = $DB->sql_like($concat,":ss$i", false);
}
$searchcond[] = $DB->sql_like($concat,":ss$i", false, true, $NOT);
$params['ss'.$i] = "%$searchterm%";
}
}
Expand Down
6 changes: 3 additions & 3 deletions message/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ function message_search($searchterms, $fromme=true, $tome=true, $courseid='none'
foreach ($searchterms as $searchterm) {
$i++;

$NOT = ''; /// Initially we aren't going to perform NOT LIKE searches, only MSSQL and Oracle
$NOT = false; /// Initially we aren't going to perform NOT LIKE searches, only MSSQL and Oracle

if ($dropshortwords && strlen($searchterm) < 2) {
continue;
Expand All @@ -1180,7 +1180,7 @@ function message_search($searchterms, $fromme=true, $tome=true, $courseid='none'
/// simpler LIKE search
if (!$DB->sql_regex_supported()) {
if (substr($searchterm, 0, 1) == '-') {
$NOT = ' NOT ';
$NOT = true;
}
$searchterm = trim($searchterm, '+-');
}
Expand All @@ -1198,7 +1198,7 @@ function message_search($searchterms, $fromme=true, $tome=true, $courseid='none'
$params['ss'.$i] = "(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)";

} else {
$searchcond[] = "m.fullmessage NOT LIKE :ss$i"; //TODO: MDL-24080
$searchcond[] = $DB->sql_like("m.fullmessage", ":ss$i", false, true, $NOT);
$params['ss'.$i] = "%$searchterm%";
}
}
Expand Down
6 changes: 1 addition & 5 deletions mod/glossary/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1238,11 +1238,7 @@ function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL)
$params['ss'.$i] = "(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)";

} else {
if ($NOT) {
$searchcond[] = "$concat NOT LIKE :ss$i"; //TODO: MDL-24080
} else {
$searchcond[] = $DB->sql_like($concat, ":ss$i", false);
}
$searchcond[] = $DB->sql_like($concat, ":ss$i", false, true, $NOT);
$params['ss'.$i] = "%$searchterm%";
}
}
Expand Down
6 changes: 1 addition & 5 deletions mod/glossary/sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,7 @@
if ($textlib->strlen($searchterm) < 2) {
continue;
}
if ($NOT) {
$searchcond[] = "$concat NOT LIKE :ss$i"; //TODO: MDL-24080
} else {
$searchcond[] = $DB->sql_like($concat, ":ss$i", false);
}
$searchcond[] = $DB->sql_like($concat, ":ss$i", false, true, $NOT);
$params['ss'.$i] = "%$searchterm%";
}
}
Expand Down
2 changes: 1 addition & 1 deletion user/filters/profilefield.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function get_sql_filter($data) {
$params[$name] = "%$value%";
break;
case 1: // does not contain
$where = "data NOT LIKE :$name"; //TODO: MDL-24080
$where = $DB->sql_like('data', ":$name", false, false, true);
$params[$name] = "%$value%";
break;
case 2: // equal to
Expand Down
2 changes: 1 addition & 1 deletion user/filters/text.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function get_sql_filter($data) {
$params[$name] = "%$value%";
break;
case 1: // does not contain
$res = "$field NOT LIKE :$name"; //TODO: MDL-24080
$res = $DB->sql_like($field, ":$name", false, false, true);
$params[$name] = "%$value%";
break;
case 2: // equal to
Expand Down

0 comments on commit 4758639

Please sign in to comment.