Home >Backend Development >PHP Tutorial >How do I use Laravel 5\'s `orWhereLike` method effectively for partial string matches?
Using Laravel-5's 'LIKE' Equivalent (Eloquent)
In Laravel 5, you can use the like operator to perform partial string matches on database columns. However, when using the orWhereLike method, it's important to carefully construct the query to ensure it produces the desired results.
To address the situation described in the question, where orWhereLike is not matching any results, you should:
BookingDates::where('email', Input::get('email')) ->orWhere('name', 'like', '%' . Input::get('name') . '%') ->get();
This modification ensures that the query searches for names containing the input value anywhere within the string.
The above is the detailed content of How do I use Laravel 5\'s `orWhereLike` method effectively for partial string matches?. For more information, please follow other related articles on the PHP Chinese website!