mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
fix: 搜索特殊字符报错的情况
This commit is contained in:
parent
1d99022ca3
commit
d149c16713
@ -164,12 +164,17 @@ class DialogController extends AbstractController
|
|||||||
// 搜索消息会话
|
// 搜索消息会话
|
||||||
if (count($list) < 20) {
|
if (count($list) < 20) {
|
||||||
$prefix = DB::getTablePrefix();
|
$prefix = DB::getTablePrefix();
|
||||||
|
if (preg_match('/[+\-><()~*"@]/', $key)) {
|
||||||
|
$against = "\"{$key}\"";
|
||||||
|
} else {
|
||||||
|
$against = "*{$key}*";
|
||||||
|
}
|
||||||
$msgs = DB::table('web_socket_dialog_users as u')
|
$msgs = DB::table('web_socket_dialog_users as u')
|
||||||
->select(['d.*', 'u.top_at', 'u.last_at', 'u.mark_unread', 'u.silence', 'u.hide', 'u.color', 'u.updated_at as user_at', 'm.id as search_msg_id'])
|
->select(['d.*', 'u.top_at', 'u.last_at', 'u.mark_unread', 'u.silence', 'u.hide', 'u.color', 'u.updated_at as user_at', 'm.id as search_msg_id'])
|
||||||
->join('web_socket_dialogs as d', 'u.dialog_id', '=', 'd.id')
|
->join('web_socket_dialogs as d', 'u.dialog_id', '=', 'd.id')
|
||||||
->join('web_socket_dialog_msgs as m', 'm.dialog_id', '=', 'd.id')
|
->join('web_socket_dialog_msgs as m', 'm.dialog_id', '=', 'd.id')
|
||||||
->where('u.userid', $user->userid)
|
->where('u.userid', $user->userid)
|
||||||
->whereRaw("MATCH({$prefix}m.key) AGAINST('*{$key}*' IN BOOLEAN MODE)")
|
->whereRaw("MATCH({$prefix}m.key) AGAINST('{$against}' IN BOOLEAN MODE)")
|
||||||
->orderByDesc('m.id')
|
->orderByDesc('m.id')
|
||||||
->take(20 - count($list))
|
->take(20 - count($list))
|
||||||
->get()
|
->get()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user