How to write the fuzzy search syntax of Eloquent ORM in Laravel5.2?
巴扎黑
巴扎黑 2017-05-16 16:54:23
0
2
525

How to write the fuzzy search syntax of Eloquent ORM in Laravel5.2?

巴扎黑
巴扎黑

reply all(2)
迷茫

It seems that you can use the where statement.

$users = DB::table('users')->where('name', 'like', '%hello%')->get();

If you need a writing method unique to a certain database, or are not used to Eloquent's method, you can also use native SQL statements (not recommended, especially since it is easy to cause SQL injection vulnerabilities due to spelling strings) - use DB: :raw method.

$users = DB::table('users')
                     ->select(DB::raw('count(*) as user_count, status'))
                     ->where('status', '<>', 1)
                     ->groupBy('status')
                     ->get();

I just moved it from the documentation. . .

漂亮男人

I recommend you an elegant writing method, which is similar to TP. Please look here
Then you can write $map = ['aa' => ['LIKE' => '%XXX%' ];

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template