Fix WHERE ... LIKE ... for SQLite
https://github.com/forkbb/forkbb/pull/10
This commit is contained in:
parent
2b546af3b9
commit
a71cb56039
3 changed files with 6 additions and 6 deletions
|
@ -54,8 +54,8 @@ class Filter extends Method
|
|||
if (false !== \strpos($rule[1], '*')) {
|
||||
// кроме * есть другие символы
|
||||
if ('' != \trim($rule[1], '*')) {
|
||||
$where[] = "b.{$field} LIKE ?{$fields[$field]}";
|
||||
$vars[] = \str_replace(['%', '*', '_'], ['\\%', '%', '\\_'], $rule[1]);
|
||||
$where[] = "b.{$field} LIKE ?{$fields[$field]} ESCAPE '#'";
|
||||
$vars[] = \str_replace(['#', '%', '_', '*'], ['##', '#%', '#_', '%'], $rule[1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -223,8 +223,8 @@ class Execute extends Method
|
|||
//???? что делать с подчеркиванием в именах?
|
||||
if ('*' !== $v->author) {
|
||||
$usePIdx = true;
|
||||
$vars[':author'] = \str_replace(['*', '?'], ['%', '_'], $v->author);
|
||||
$whereIdx[] = 'p.poster LIKE ?s:author';
|
||||
$vars[':author'] = \str_replace(['#', '_', '*', '?'], ['##', '#_', '%', '_'], $v->author);
|
||||
$whereIdx[] = 'p.poster LIKE ?s:author ESCAPE \'#\'';
|
||||
}
|
||||
|
||||
$this->model->showAs = $v->show_as;
|
||||
|
|
|
@ -54,8 +54,8 @@ class Filter extends Action
|
|||
if (false !== \strpos($rule[1], '*')) {
|
||||
// кроме * есть другие символы
|
||||
if ('' != \trim($rule[1], '*')) {
|
||||
$where[] = "u.{$field} LIKE ?{$fields[$field]}";
|
||||
$vars[] = \str_replace(['%', '*', '_'], ['\\%', '%', '\\_'], $rule[1]);
|
||||
$where[] = "u.{$field} LIKE ?{$fields[$field]} ESCAPE '#'";
|
||||
$vars[] = \str_replace(['#', '%', '_', '*'], ['##', '#%', '#_', '%'], $rule[1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue