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
Post a Comment