php - Mysql Search "I" Case Insensitive -


i'm working laravel project, , noticed problem. in database (mysql) fields stored uppercase. when search below, have problem.

$query->where(function ($query) use ($q) {     $query->orwhere('product', 'like', '%'.$q.'%');     $query->orwhere('stock_code', 'like', '%'.$q.'%');     $query->orwhere('barcode', 'like', '%'.$q.'%');     $query->orwhere('hs_code', 'like', '%'.$q.'%'); }); 

for example findik turkish word. , when user search fındık no results found.

i'm using unicode_general_ci mysql tables. , head codes below.

<!doctype html> <html lang="tr"> <head>     <meta charset="utf-8"> 

what should do? people offers mysql lower method. hope there exists better way.

$query->where(function ($query) use ($q) {     $query->orwhere('product', 'ilike', '%'.$q.'%');     $query->orwhere('stock_code', 'ilike', '%'.$q.'%');     $query->orwhere('barcode', 'ilike', '%'.$q.'%');     $query->orwhere('hs_code', 'ilike', '%'.$q.'%'); }); 

please try use ilike


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -