laravel paginator在where子句中不与LIKE一起使用
laravel / framework版本:v5.6.33
控制者
$search_qs = $request->input('search');
$query = Article::where("status", 2);
$query->where('title', 'LIKE', '%' . $search_qs . '%');
$articles = $query->paginate(3);
Run Code Online (Sandbox Code Playgroud)
视图
{{ $articles->links() }}
Run Code Online (Sandbox Code Playgroud)
数据库查询
select * from `articles` where `status` = '2' and `title` LIKE '%txt2search%' limit 3 offset 0
Run Code Online (Sandbox Code Playgroud)
!!! 好 !!!
但是,当我单击分页器的第2页时
select * from `articles` where `status` = '2' and `title` LIKE '%%' limit 3 offset 3
Run Code Online (Sandbox Code Playgroud)
绑定
0. 2 (`status` = ?)
1. %% (`title` LIKE ?)
Run Code Online (Sandbox Code Playgroud)
值应存储在session或flash_session中?但是未检索到LIKE值
$articles = $query->paginate(3)->appends($request->only('search_qs'));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
44 次 |
| 最近记录: |