更新数据库当前字段

时间:2015-12-03 10:09:31

标签: php mysql sql database codeigniter

如何仅更新my_field

$this->db->set('my_field', 'my_field+1', FALSE);
$this->db->where('my_other_field', 'test');
$this->db->update('my_table');

2 个答案:

答案 0 :(得分:0)

尝试这样,

$data['my_field'] = "value";

$this->db->where("");//where condition here
$this->db->update("tablename",$data);

或一线解决方案,

$this->db->update('tablename', $data, "where condition");

修改

$this->db->query("update my_table set my_field = my_field + 1 where my_other_field = test");

答案 1 :(得分:0)

{{1}}