I am using a grid to display businesses. I'm going to strip down our laravel call to bare minimum so lets say I have about 20,000 businesses and I don't want to load them all if I don't need to. So I am showing a search bar before the grid is loaded to type and query and based on their search input, I load what matches using Laravel into the grid.
The issue I am having is with Special Characters. If in the DB I have a Business Name of Lucky's Bar, and the users search input is Luckys Bar w/o the apostrophe, it doesn't find the result. Same with slashes or dashes.
What is the best approach to accomplishing this?
PHP - Search Statement
public function search($search_input) {
$response = DB::table(self::$table)
->select(array(
'ID',
'Signup_Date',
'Business_Name'
))
->where('Business_Name', 'LIKE', '%'.$search_input.'%')
->order_by('Signup_Date', 'desc')
->get();
return $response;
}
Using Laravel 3, yes I know it is outdated, we have plans to upgrade, but this is a current issue that needs fixing. https://laravel3.veliovgroup.com/docs/database/fluent
One way, which might be unacceptably slow, is
WHERE REPLACE(field, "'", "") LIKE 'tam osha%"
where in the DB it is stored as Tam O'Shanter
.