原sql写法:
update table set a=a+b where id=1;
TP框架写法:
$where = $setData = array();
$where['id'] = 1;
$setData['a'] = array('exp', 'a+b');
M('table')->where($where)->save($setData);
本文介绍使用ThinkPHP框架更新数据库记录的方法,通过设置SQL表达式实现字段的自增操作。示例展示了如何将表中ID为1的记录中A字段的值更新为其自身与B字段之和。
原sql写法:
update table set a=a+b where id=1;
TP框架写法:
$where = $setData = array();
$where['id'] = 1;
$setData['a'] = array('exp', 'a+b');
M('table')->where($where)->save($setData);
4171

被折叠的 条评论
为什么被折叠?