$users = DB::table('users')->get();
返回值:数组结果,其中每一个结果都是 StdClass$user = DB::table('users')->first();
返回值:单个 StdClass 实例$user = User::first();
返回值:Eloquent 对象`$user = User::find();
返回值:Eloquent 对象`$users = User::get();
返回值:Eloquent 集合$users = User::all();
返回值:Eloquent 集合$user = User::create($data);
返回值:Eloquent 对象$user = new User();
$user->name = "admin"
$user->save();
返回值:Eloquent 对象
7. $result = User::insert($data);
返回值:bool
8. $result = $user->delete();
返回值:bool
9. $count = User::destroy([1, 2]);
返回值:删除记录数
10. $count = User::where('id', '>', 1)->delete();
返回值:删除记录数
11. $count = User::where('id', '>', 10)->update(['status' => 1]);
返回值:更新记录数
11. $count = User::where('id', '>', 10)->increment('age', 1);
返回值:更新记录数
整理自网络
本文为秋叶听风原创文章,转载无需和我联系,但请注明来自秋叶听风博客http://ice90.cn
最新评论