I want to implement case insensitive search following is my code for search
/*get the title to search*/
$newsTitle=Input::get('srach_newsTitle')?Input::get('srach_newsTitle'):'';
$query = DB::table('news');
if( strlen($newsTitle) )
{
$query->whereRaw('LOWERCASE(`newsTitle`) LIKE ? ',[trim(strtolower($newsTitle)).'%']);
}
but its says function LOWERCASE is not Defined in My projects following is the error message
QueryException in Connection.php line 729:
SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION cpr-laravel.LOWERCASE does not exist (SQL: select count(*) as aggregate from news
where LOWERCASE(newsTitle
) LIKE test%)
whats wrong i am doing?plz help
Use LOWER()
$query->whereRaw('LOWER(`newsTitle`) LIKE ? ',[trim(strtolower($newsTitle)).'%']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With