ThinkPHP使用update函数更新数据的方法

2022-07-2909:42:40后端程序开发Comments1,596 views字数 261阅读模式

update 方法返回影响数据的条数,没修改任何数据返回 0

  1. Db::table('user')
  2.     ->where('id', 1)
  3.     ->update(['name' => 'zhimatong']);

更新多个字段的写法:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/26195.html

  1. Db::table('user')
  2.     ->where('id', 1)
  3.     ->update([
  4.         'login_time'  => ['exp','now()'],
  5.         'login_times' => ['exp','login_times+1'],
  6.     ]);
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/26195.html
  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/bc/26195.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定