数据库更新字段问题
----------------------------------------|id |value1 |value2 |value3
----------------------------------------
|1 |1 |3 |此值等于value1+value2
----------------------------------------
不用$this->db->query()
如何使某个字段的值等于其他两个字段的值的和?
直接写sql有什么问题吗?
update tables set values3 = value1+value2 where id = 1
CI本身貌似没有 直接可以使用的,不过你可以自己封装一个
或
先查出字段1,字段2的数据来相同再更新
this->db->select('a,b')->where($where)->get(table);
$this->db->where()->update('tables',array(value3=>(值1+值2)))
页:
[1]