Mukesh Yadav
Mukesh Yadav

Reputation: 2386

Codigniter active record update query taking old where clause

I have a following query

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

Above Query is producing below sql code. even though I'm supplying only one where condition.

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

I think active record is using some cached where condition, is there any way I can free where condition.
I tried using

$this->db->flush_cache();

But it's not helping.

Upvotes: 0

Views: 2141

Answers (2)

Mikhail
Mikhail

Reputation: 2562

Your query is fully correct. But I believe what you used a $this->db->where() before current query. Use the following code and you will see all the previously defined "where" statements:

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

Upvotes: 1

stormdrain
stormdrain

Reputation: 7895

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

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

is incorrect.

->where('id',$user_id)

is correct.

Upvotes: 3

Related Questions