WhereRaw Laravel with variable
问题 I'm trying to do this query but I got an error (Malformed UTF-8 characters, possibly incorrectly encoded): DB::table('my_table')->select(DB::raw("id")) ->whereRaw('UPPER(name)','=', $upper_name) ->pluck('id')->first(); I'm trying to add the UPPER sql function to the query. With direct sql, the query should be: select * from my_table where UPPER(name) = 'HELLO' Where $upper_name = HELLO. 回答1: Simpliest Way to do that. Hope will help you DB::table('my_table')->select('id') ->where(DB::raw(