Codinger活动记录更新查询采用旧的where子句


Codigniter active record update query taking old where clause

我有以下查询

$this->db->set('registerStep', $param)
 ->where('id = ',$user_id)
 ->update($this->table_name);

Above Query正在生成以下sql代码。尽管我只提供一个有条件的。

 UPDATE `users` SET `registerStep` = 2 WHERE `id` = 33 AND `id` = '165'

我认为活动记录使用了一些缓存的where条件,有没有任何方法可以释放where条件
我试过使用

$this->db->flush_cache();

但这于事无补。

http://codeigniter.com/user_guide/database/active_record.html#update

->where('id = ',$user_id)

不正确。

->where('id',$user_id)

是正确的。

您的查询完全正确。但我相信您在当前查询之前使用了$this->db->where()。使用以下代码,您将看到所有先前定义的"where"语句:

print_r($this->db->ar_where);
$this->db->set('registerStep', $param)
     ->where('id = ',$user_id)
     ->update($this->table_name);