Reputation: 779
I'm trying to make a where ... like in Laravel with MongoDb for my search bar. In mysql I created with:
DB::table('Account')->where('avail_balance','like','%' .$searchValue . '%');
But with MongoDb Jenssegers, I can't use it. It's return nothing.
After search some post in here, I use:
$account = DB::connection('mongodb')->collection('Account')->where('avail_balance',"%{$searchValue}%")->paginate(5);
It's still return nothing.
How I should convert this query from mysql to mongodb?
Thank you very much!
Upvotes: 1
Views: 7535
Reputation: 1981
Try this with the end of get()
method:
DB::table('Account')->where('avail_balance','LIKE','%'.$searchValue.'%')->get();
And try this using LIKE
query:
$account = DB::connection('mongodb')->collection('Account')->where('avail_balance','LIKE','%'.$searchValue.'%')->paginate(5);
I hope it would helpful.
Upvotes: 3