1use Illuminate\Support\Facades\DB;
2
3$users = DB::select('select * from users');
4
5foreach ($users as $user) {
6 echo $user->name;
7}
1/*
2whereRaw / orWhereRaw
3The whereRaw and orWhereRaw methods can
4be used to inject a raw "where" clause into your query.
5These methods accept an optional array of bindings as their second argument:
6*/
7$orders = DB::table('orders')
8 ->whereRaw('price > IF(state = "TX", ?, 100)', [200])
9 ->get();
1$query->whereRaw("(
2 LOWER(name) like '%". strtolower($search) ."%' OR
3 LOWER(sku) like '%". strtolower($search) ."%' OR
4 LOWER(codigo) like '%". strtolower($search) ."%' OR
5 LOWER(descricao_curta) like '%". strtolower($search) ."%'
6 )");