摘要: 在laravel框架里面,有自增自减的函数: DB::table('users')->increment('votes'); DB::table('users')->increment('votes', 5); DB::table('users')->decrement('votes'); DB:: 阅读全文
posted @ 2022-07-14 11:11 帅到要去报警 阅读(383) 评论(0) 推荐(0) 编辑
摘要: 今天阅读laravel文档,整理了一些常用的查询构造器: 一、获取所有行 $users = DB::table('users')->get(); // 区别 Think 的 Select 二、获取单行/列 $user = DB::table('users')->where('name', 'John 阅读全文
posted @ 2022-07-14 10:48 帅到要去报警 阅读(918) 评论(0) 推荐(0) 编辑
摘要: 使用laravel框架,数据库的事务怎么做呢? 通常使用到事务,控制层或服务层通常需要使用【Db】来处理事务: 示例代码1: DB::transaction(function () { DB::table('users')->update(['votes' => 1]); DB::table('po 阅读全文
posted @ 2022-07-14 10:37 帅到要去报警 阅读(643) 评论(0) 推荐(0) 编辑