Welcome Guest, Not a member yet? Register   Sign In
Active Record: add +1 to current value (update)
#7

[eluser]cahva[/eluser]
If you're trying to update the password with a new one, then you should do it like you normally update a record:
Code:
$this->db->set('password', $password);
$this->db->where('id', $id);
$this->db->update('workers');

..or
Code:
$arr = array(
    'password' => $password
);
$this->db->where('id', $id);
$this->db->update('workers',$arr);

The initial problem for this thread is that the user wanted to update the existing record incrementing it by one. The third parameter false will tell CI not to escape the generated SQL and therefore you can do somefield=somefield+1. Without the third parameter set to false, CI would create the sql like: somefield='somefield + 1' which is not the same.


Messages In This Thread
Active Record: add +1 to current value (update) - by El Forum - 04-07-2011, 10:07 AM
Active Record: add +1 to current value (update) - by El Forum - 04-07-2011, 10:30 AM
Active Record: add +1 to current value (update) - by El Forum - 04-07-2011, 10:46 AM
Active Record: add +1 to current value (update) - by El Forum - 05-28-2011, 10:50 AM
Active Record: add +1 to current value (update) - by El Forum - 05-28-2011, 01:21 PM
Active Record: add +1 to current value (update) - by El Forum - 05-28-2011, 01:43 PM
Active Record: add +1 to current value (update) - by El Forum - 05-28-2011, 02:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB