Skip to content
Browse files

Fixed searches, list of results and simplified SQL logic. All

those while trying to fix one LCASE() use. MDL-7310
  • Loading branch information...
1 parent 92b2d0f commit 5cc8148eb8ecf36dc4632ce667499322916b548e stronk7 committed Oct 31, 2006
Showing with 5 additions and 16 deletions.
  1. +5 −16 mod/wiki/ewikimoodlelib.php
View
21 mod/wiki/ewikimoodlelib.php
@@ -235,22 +235,11 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
$field = implode("", array_keys($args));
$content = strtolower(implode("", $args));
if ($field == "id") { $field = "pagename"; }
- switch ($CFG->dbtype) {
- case 'postgres7':
- $sql= "SELECT pagename AS id, version, flags" .
- (EWIKI_DBQUERY_BUFFER && ($field!="pagename") ? ", $field" : "") .
- " FROM " . $CFG->prefix.EWIKI_DB_TABLE_NAME .
- " WHERE $field ILIKE '%".anydb_escape_string($content)."%' and wiki=".$wiki_entry->id .
- " GROUP BY id, pagename, version, flags ".
- (EWIKI_DBQUERY_BUFFER && ($field!="pagename") ? ", $field" : "") ;
- break;
- default:
- $sql= "SELECT pagename AS id, version, flags" .
- (EWIKI_DBQUERY_BUFFER && ($field!="pagename") ? ", $field" : "") .
- " FROM " . $CFG->prefix.EWIKI_DB_TABLE_NAME .
- " WHERE LOCATE('" . anydb_escape_string($content) . "', LCASE($field)) and wiki=".$wiki_entry->id .
- " GROUP BY id, version DESC";
- }
+ $sql= "SELECT pagename AS id, version, flags" .
+ (EWIKI_DBQUERY_BUFFER && ($field!="pagename") ? ", $field" : "") .
+ " FROM " . $CFG->prefix.EWIKI_DB_TABLE_NAME .
+ " WHERE $field " . sql_ilike() . " '%".anydb_escape_string($content)."%' and wiki=".$wiki_entry->id .
+ " ORDER BY id, version ASC";
$result=get_records_sql($sql);
$r = new ewiki_dbquery_result(array("id","version",$field));

0 comments on commit 5cc8148

Please sign in to comment.
Something went wrong with that request. Please try again.