2012-02-21 69 views
0

我有以下查询Codigniter活动记录更新查询到老where子句

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

以上查询是生产以下SQL代码。即使我只提供一个条件。

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

我认为活动记录是使用一些缓存where条件,有什么办法,我可以自由where条件。
我尝试使用

$this->db->flush_cache(); 

但它没有帮助。

+0

尝试在$ user_ID的一个的var_dump,看看它是在该行之前设定的权利。 – 2012-02-21 14:59:58

+1

为什么不试试$ this-> db-> where('id',$ id); $ this-> db-> update('users',$ param); – 2012-02-21 15:02:02

+0

我试过'$ this-> db-> where('id',$ id); $ this-> db-> update('users',$ param);'但它没有帮助 – 2012-03-10 15:20:28

回答

1

您的查询完全正确。但我相信你在当前查询之前使用了$ this-> db-> where()。使用下面的代码,你会看到所有的先前定义的“其中”声明:

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