//查询构造器
public function query()
{
$bool = DB::table('student')->insert([
['name' => '王五', 'age' => 17, 'gender' => 1],
['name' => '王五2', 'age' => 17, 'gender' => 1]
]);
var_dump($bool); //获取插入的数据的id
$student_id = DB::table('student')->insertGetId(
['name' => '赵六', 'age' => 19, 'gender' => 2]
);
var_dump($student_id); //更新数据,返回影响的行数
$num = DB::table('student')->where('id',1)->update(
['age' => 20, 'gender' => 2]
);
var_dump($num); //更新数据,自增字段,返回影响的行数
$num = DB::table('student')->where('id',1)->increment('age');//自增1
$num = DB::table('student')->where('id',1)->increment('age',3);//自增3
$num = DB::table('student')->where('id',1)->decrement('age',3);//自减3
var_dump($num); //更新数据,自增以及其他字段修改
$num = DB::table('student')->where('id',1)->increment('age',3,['name'=>'haha']); //删除数据,返回删除的行数
$num = DB::table('student')->where('id',1)->delete();
$num = DB::table('student')->where('id','>=',10)->delete(); //清空数据,不返回任何东西
$num = DB::table('student')->truncate(); }

最新文章

  1. JFinal学习
  2. web测试安全性常见问题
  3. (实用篇)PHP递归实现无限级分类
  4. List Copy
  5. leetcode 116- Populating Next Right Pointers in Each Node
  6. 在cmd中登录ftp服务器
  7. Paxos算法之旅(四)zookeeper代码解析--转载
  8. Hibernate + MySQL中文乱码问题
  9. Android获取本机IP地址
  10. Webpack学习笔记(一)
  11. swift学习 - collectionView
  12. Oracle12c 在windonServer2012中安装的步骤
  13. SQL Server Profiler的使用
  14. Day8--------------RPM包管理
  15. ACC自适应巡航控制系统介绍
  16. Django-基础-2-ORM
  17. WINDOWS中, 如何查看一个运行中的程序是64位还是32位的
  18. OOP⑻
  19. Windows server 安装
  20. jetty 热部署

热门文章

  1. python在d盘,robotframework引入seleniumlibrary报错
  2. a标签目标链接问题
  3. VS2019 KEY
  4. Java常见对象Object类中的个别方法
  5. C# 队列Queue
  6. iOS 第三方类库之MBProgressHUD
  7. 使用xib开发界面
  8. BZOJ 4016 最短路径树问题 最短路径树构造+点分治
  9. RuntimeError: Failed to init API, possibly an invalid tessdata path: E:\python36\报错
  10. Python2.7 在使用BSTestRunner.py时报错TypeError: unicode argument expected, got 'str'