laravel5基于Eloquent ORM进行like模糊查询

laravel5基于Eloquent ORM进行like模糊查询

$res= User::where('username','like', '%'.$keywords.'%')->orderby('id','desc')->paginate(15);

laravel 多个条件模糊查询

$keywords= $request->input('keywords');
$articles = DB::table('articles')
                ->where('content', 'like', $keywords.'%')
                ->orWhere('title', 'like', $keywords.'%')
                ->get();

使用Like搜索中文是不需要其它设置或操作的,对于这种全文搜索操作不建议使用like,最好是使用搜索引擎如ElasticSearch或者Sphinx等工具来实现

本博客所有文章如无特别注明均为原创。作者:小乐复制或转载请以超链接形式注明转自 众众帮
原文地址《laravel5基于Eloquent ORM进行like模糊查询
分享到:更多

相关推荐

发表评论

路人甲 表情
Ctrl+Enter快速提交

网友评论(0)