1 update
更新一到多条数据
update方法有3个参数,第1个参数是要更新的数据,后2个参数可选,分别用来指定主键值和主键名,
$db->post->update(['content' => '更新内容'], 1);
$db->post->where('id', 1)->update(['content' => '更新内容']);
执行结果返回更新数据条数
2 updateAuto
自增 自减方式自动更新数据
updateAuto方法有2个参数,第1个参数是要自动更新的数据,第2个参数是普通更新数据(默认为空)
// 帐号积分加1
$db->account->where('id', 1)->updateAuto(['score' => 1]);
// foo加1,bar加2,baz减1
$db->table->updateAuto(['foo' => 1, 'bar' => 2, 'baz' => -1]);