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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| public function query1() { $bool = DB::table('student')->insert( ['name' => 'mohuani', 'age' => 19] ); var_dump($bool);
$id = DB::table('student')->insertGetId( ['name' => 'sean', 'age' => 18] ); var_dump($id);
$id = DB::table('student')->insert([ ['name' => 'name1', 'age' => 21], ['name' => 'name2', 'age' => 22] ]); var_dump($id);
}
public function query2() { $sum = DB::table('student') ->where('id', 1001) ->update(['age' => 30]); var_dump($sum);
$sum = DB::table('student')->increment('age'); $sum = DB::table('student')->increment('age', 3);
$sum = DB::table('student')->decrement('age'); $sum = DB::table('student')->decrement('age', 3);
$num = DB::table('student') ->where('id', 1004) ->decrement('age', 3); var_dump($num);
$num = DB::table('student') ->where('id', 1004) ->decrement('age', 3, ['name' => 'iimooc']); var_dump($num); }
public function query3() { $num = DB::table('student') ->where('id',1008) ->delete(); var_dump($num);
$num = DB::table('student') ->where('id', '>=', 1008) ->delete(); var_dump($num);
DB::table('student')->truncate(); }
|