replace ILIKE with the better-supported LOWER

This commit is contained in:
Shish 2019-12-15 16:09:48 +00:00
parent d7a2ca9ddc
commit 090ff65109
3 changed files with 4 additions and 8 deletions

View file

@ -6,7 +6,6 @@ abstract class SCORE
const BOOL_Y = "SCORE_BOOL_Y";
const BOOL_N = "SCORE_BOOL_N";
const BOOL = "SCORE_BOOL";
const ILIKE = "SCORE_ILIKE";
}
abstract class DBEngine
@ -54,7 +53,6 @@ class MySQL extends DBEngine
$data = str_replace(SCORE::BOOL_Y, "'$this->BOOL_Y'", $data);
$data = str_replace(SCORE::BOOL_N, "'$this->BOOL_N'", $data);
$data = str_replace(SCORE::BOOL, "ENUM('Y', 'N')", $data);
$data = str_replace(SCORE::ILIKE, "LIKE", $data);
return $data;
}
@ -99,7 +97,6 @@ class PostgreSQL extends DBEngine
$data = str_replace(SCORE::BOOL_Y, $this->BOOL_Y, $data);
$data = str_replace(SCORE::BOOL_N, $this->BOOL_N, $data);
$data = str_replace(SCORE::BOOL, "BOOL", $data);
$data = str_replace(SCORE::ILIKE, "ILIKE", $data);
return $data;
}
@ -193,7 +190,6 @@ class SQLite extends DBEngine
$data = str_replace(SCORE::BOOL_Y, "'$this->BOOL_Y'", $data);
$data = str_replace(SCORE::BOOL_N, "'$this->BOOL_N'", $data);
$data = str_replace(SCORE::BOOL, "CHAR(1)", $data);
$data = str_replace(SCORE::ILIKE, "LIKE", $data);
return $data;
}

View file

@ -139,11 +139,11 @@ class NotATag extends Extension
$where = ["(1=1)"];
$args = ["limit"=>$size, "offset"=>($page-1)*$size];
if (!empty($_GET['tag'])) {
$where[] = 'tag SCORE_ILIKE :tag';
$where[] = 'LOWER(tag) LIKE LOWER(:tag)';
$args["tag"] = "%".$_GET['tag']."%";
}
if (!empty($_GET['redirect'])) {
$where[] = 'redirect SCORE_ILIKE :redirect';
$where[] = 'LOWER(redirect) LIKE LOWER(:redirect)';
$args["redirect"] = "%".$_GET['redirect']."%";
}
$where = implode(" AND ", $where);

View file

@ -283,7 +283,7 @@ class TagList extends Extension
FLOOR(LOG(2.7, LOG(2.7, count - :tags_min2 + 1)+1)*1.5*100)/100 AS scaled
FROM tags
WHERE count >= :tags_min
AND tag SCORE_ILIKE :starts_with
AND LOWER(tag) LIKE LOWER(:starts_with)
ORDER BY LOWER(tag)
"), ["tags_min"=>$tags_min, "tags_min2"=>$tags_min, "starts_with"=>$starts_with]);
@ -326,7 +326,7 @@ class TagList extends Extension
SELECT tag, count
FROM tags
WHERE count >= :tags_min
AND tag SCORE_ILIKE :starts_with
AND LOWER(tag) LIKE LOWER(:starts_with)
ORDER BY LOWER(tag)
"), ["tags_min"=>$tags_min, "starts_with"=>$starts_with]);