1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| public function query4() { $student = DB::table('student')->get(); dd($student);
$student = DB::table('student')->first(); dd($student);
$student = DB::table('student') ->orderBy('id', 'desc') ->first(); dd($student); $student = DB::table('student') ->where('id', '>=', 1002) ->get(); dd($student);
$student = DB::table('student') ->whereRaw('id >= ? and age > ?', [1002, 20]) ->get(); dd($student);
$name = DB::table('student') ->pluck('name'); dd($name);
$name = DB::table('student') ->lists('name', 'id'); dd($name);
$student = DB::table('student') ->select('id' ,'name', 'age') ->get(); dd($student);
echo '<pre>'; DB::table('student')->chunk(2, function ($student){ var_dump($student); }); }
|