Merge pull request #682 from DanielOaks/develop+fix-sqlite-underscores
Fix SQLite underscore searching
This commit is contained in:
commit
dbaf34f7c3
@ -944,12 +944,16 @@ class Image
|
|||||||
$negative_tag_id_array = [];
|
$negative_tag_id_array = [];
|
||||||
|
|
||||||
foreach ($tag_conditions as $tq) {
|
foreach ($tag_conditions as $tq) {
|
||||||
$tag_ids = $database->get_col(
|
$sq = "
|
||||||
$database->scoreql_to_sql("
|
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM tags
|
FROM tags
|
||||||
WHERE SCORE_STRNORM(tag) LIKE SCORE_STRNORM(:tag)
|
WHERE SCORE_STRNORM(tag) LIKE SCORE_STRNORM(:tag)
|
||||||
"),
|
";
|
||||||
|
if ($database->get_driver_name() === DatabaseDriver::SQLITE) {
|
||||||
|
$sq .= "ESCAPE '\\'";
|
||||||
|
}
|
||||||
|
$tag_ids = $database->get_col(
|
||||||
|
$database->scoreql_to_sql($sq),
|
||||||
["tag" => Tag::sqlify($tq->tag)]
|
["tag" => Tag::sqlify($tq->tag)]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -103,6 +103,10 @@ class Tag
|
|||||||
|
|
||||||
public static function sqlify(string $term): string
|
public static function sqlify(string $term): string
|
||||||
{
|
{
|
||||||
|
global $database;
|
||||||
|
if ($database->get_driver_name() === DatabaseDriver::SQLITE) {
|
||||||
|
$term = str_replace('\\', '\\\\', $term);
|
||||||
|
}
|
||||||
$term = str_replace('_', '\_', $term);
|
$term = str_replace('_', '\_', $term);
|
||||||
$term = str_replace('%', '\%', $term);
|
$term = str_replace('%', '\%', $term);
|
||||||
$term = str_replace('*', '%', $term);
|
$term = str_replace('*', '%', $term);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user