Skip to content

Commit

Permalink
Now forum searches are working both under MSSQL and Oracle
Browse files Browse the repository at this point in the history
(in a case-sensitive behaviour for Oracle, see code comments and
http://docs.moodle.org/en/XMLDB_Problems#Case-insensitive_searches)
  • Loading branch information
stronk7 committed Sep 6, 2006
1 parent 43149d3 commit 8289a52
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mod/forum/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1182,17 +1182,18 @@ function forum_search_posts($searchterms, $courseid, $page=0, $recordsperpage=50
$timelimit = " AND (d.userid = $USER->id OR ((d.timestart = 0 OR d.timestart <= $now) AND (d.timeend = 0 OR d.timeend > $now)))";
}

$limit = sql_paging_limit($page, $recordsperpage);
$limitfrom = $page;
$limitnum = $recordsperpage;

/// Some differences in syntax for PostgreSQL
if ($CFG->dbtype == "postgres7") {
$LIKE = "ILIKE"; // case-insensitive
$NOTLIKE = "NOT ILIKE"; // case-insensitive
$REGEXP = "~*";
$NOTREGEXP = "!~*";
} else {
$LIKE = "LIKE";
$NOTLIKE = "NOT LIKE";
} else { //Note the LIKE are casesensitive for Oracle. Oracle 10g is required to use
$LIKE = "LIKE"; //the caseinsensitive search using regexp_like() or NLS_COMP=LINGUISTIC :-(
$NOTLIKE = "NOT LIKE"; //See http://docs.moodle.org/en/XMLDB_Problems#Case-insensitive_searches
$REGEXP = "REGEXP";
$NOTREGEXP = "NOT REGEXP";
}
Expand Down Expand Up @@ -1228,7 +1229,7 @@ function forum_search_posts($searchterms, $courseid, $page=0, $recordsperpage=50
$totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");

return get_records_sql("SELECT p.*,d.forum, u.firstname,u.lastname,u.email,u.picture FROM
$selectsql ORDER BY p.modified DESC $limit");
$selectsql ORDER BY p.modified DESC", $limitfrom, $limitnum);
}


Expand Down

0 comments on commit 8289a52

Please sign in to comment.