mirror of
https://github.com/moodle/moodle.git
synced 2025-06-02 22:25:04 +02:00
Better behaviour for "-" course searches under MSSQL and Oracle. MDL-7312 ; merged from 19_STABLE
This commit is contained in:
parent
8edf2cdce3
commit
0f62a5b5bb
@ -1058,9 +1058,15 @@ function get_courses_search($searchterms, $sort='fullname ASC', $page=0, $record
|
||||
|
||||
foreach ($searchterms as $searchterm) {
|
||||
|
||||
$NOT = ''; /// Initially we aren't going to perform NOT LIKE searches, only MSSQL and Oracle
|
||||
/// will use it to simulate the "-" operator with LIKE clause
|
||||
|
||||
/// Under Oracle and MSSQL, trim the + and - operators and perform
|
||||
/// simpler LIKE search
|
||||
/// simpler LIKE (or NOT LIKE) queries
|
||||
if ($CFG->dbfamily == 'oracle' || $CFG->dbfamily == 'mssql') {
|
||||
if (substr($searchterm, 0, 1) == '-') {
|
||||
$NOT = ' NOT ';
|
||||
}
|
||||
$searchterm = trim($searchterm, '+-');
|
||||
}
|
||||
|
||||
@ -1080,8 +1086,8 @@ function get_courses_search($searchterms, $sort='fullname ASC', $page=0, $record
|
||||
$summarysearch .= " c.summary $NOTREGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
$fullnamesearch .= " c.fullname $NOTREGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
} else {
|
||||
$summarysearch .= ' c.summary '. $LIKE .' \'%'. $searchterm .'%\' ';
|
||||
$fullnamesearch .= ' c.fullname '. $LIKE .' \'%'. $searchterm .'%\' ';
|
||||
$summarysearch .= ' summary '. $NOT . $LIKE .' \'%'. $searchterm .'%\' ';
|
||||
$fullnamesearch .= ' fullname '. $NOT . $LIKE .' \'%'. $searchterm .'%\' ';
|
||||
}
|
||||
|
||||
}
|
||||
@ -1092,7 +1098,7 @@ function get_courses_search($searchterms, $sort='fullname ASC', $page=0, $record
|
||||
FROM {$CFG->prefix}course c
|
||||
JOIN {$CFG->prefix}context ctx
|
||||
ON (c.id = ctx.instanceid AND ctx.contextlevel=".CONTEXT_COURSE.")
|
||||
WHERE ( $fullnamesearch OR $summarysearch )
|
||||
WHERE (( $fullnamesearch ) OR ( $summarysearch ))
|
||||
AND category > 0
|
||||
ORDER BY " . $sort;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user