1


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!

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.