thinkphp-更新数据update函数
时间:2017-02-10 18:47:24
收藏:0
阅读:1944
说明
update 方法返回影响数据的条数,没修改任何数据返回 0
示例1
Db::table(‘think_user‘) ->where(‘id‘, 1) ->update([‘name‘ => ‘thinkphp‘]);
输出
1
数据中包含主键形式
示例2
Db::table(‘think_user‘) ->update([‘name‘ => ‘thinkphp‘,‘id‘=>1]);
输出
1
使用SQL
函数或者其它字段进行更新
Db::table(‘think_user‘) ->where(‘id‘, 1) ->update([ ‘login_time‘ => [‘exp‘,‘now()‘], ‘login_times‘ => [‘exp‘,‘login_times+1‘], ]);
本文出自 “素颜” 博客,请务必保留此出处http://suyanzhu.blog.51cto.com/8050189/1896691
评论(0)