1.添加数据
DB::table("users")->insert($data); 2.单条查询
DB::table("users")->where('username','zhangsan')->first();3.查询全部
DB::table("users")->select("username")->get();
4.删除
DB::table("users")->where("id",'=',$id)->delete();5.修改
DB::table("users")->where("id",'=','2')->update($data);6.join使用
DB::table("users")->join('uc', 'users.id', '=', 'uc.user_id')
->join('cl', 'cl.id', '=', 'uc.class_id')
->select("*")
->get();7.偏移(offset)限制 (limit)DB::table("users")->skip(10)->take(5)->get();8.order by 、group by、havingDB::table('users')
->orderBy('id', 'desc')
->groupBy('count')
->having('count', '>', 100)
->get();
本文介绍了使用 Laravel 框架进行数据库操作的方法,包括数据的添加、查询、更新、删除等基本操作,并展示了如何使用 join、order by、group by 和 having 等高级查询技巧。
167

被折叠的 条评论
为什么被折叠?



