优化后端
This commit is contained in:
@@ -16,12 +16,15 @@ class Article extends Base
|
||||
if (Request::isPost()) {
|
||||
$category = input('post.category');
|
||||
$page = input('post.page', 1);
|
||||
$limit = input('post.limit', 20);
|
||||
$limit = input('post.limit', 10);
|
||||
$title = input('post.title');
|
||||
$author = input('post.author');
|
||||
|
||||
$query = Db::table('yz_article')
|
||||
->where('delete_time', null)
|
||||
->where('status', '<>', 3);
|
||||
|
||||
// 分类筛选
|
||||
if (!empty($category)) {
|
||||
// 先获取分类ID
|
||||
$cateInfo = Db::table('yz_article_category')
|
||||
@@ -34,6 +37,16 @@ class Article extends Base
|
||||
$query = $query->where('cate', $cateInfo['id']);
|
||||
}
|
||||
}
|
||||
|
||||
// 标题搜索
|
||||
if (!empty($title)) {
|
||||
$query = $query->where('title', 'like', '%'.$title.'%');
|
||||
}
|
||||
|
||||
// 作者搜索
|
||||
if (!empty($author)) {
|
||||
$query = $query->where('author', 'like', '%'.$author.'%');
|
||||
}
|
||||
|
||||
// 获取总记录数
|
||||
$count = $query->count();
|
||||
|
||||
Reference in New Issue
Block a user