在Laravel中使用雄辩的ORM,使用LIKE执行数据库的搜索 [英] Using Eloquent ORM in Laravel to perform search of database using LIKE

查看:111
本文介绍了在Laravel中使用雄辩的ORM,使用LIKE执行数据库的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Eloquent的活跃记录建立一个搜索查询,但它将是一个喜欢的搜索。我发现 User :: find($ term) User :: find(1),但这是不生成类似的语句。我不是在寻找一个直接的答案,但如果有人至少可以给我一个方向来看看那将是很棒的!

I want to use Eloquent's active record building to build a search query, but it is going to be a LIKE search. I have found the User::find($term) or User::find(1), but this is not generating a like statement. I'm not looking for a direct answer, but if someone could at least give me a direction to look in that'd be great!

推荐答案

您可以使用以下语法使用LIKE进行数据库查找:

You're able to do database finds using LIKE with this syntax:

Model::where('column', 'LIKE', '%value%')->get();

这篇关于在Laravel中使用雄辩的ORM,使用LIKE执行数据库的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆