Welcome Guest, Not a member yet? Register   Sign In
Active Record gotcha
#1

[eluser]Michael Ekoka[/eluser]
in the following code I want to update the password field in one record :

Code:
$form_data = $this->input->post('form_data');

// I get my input from a form
$user_id = $form_data['user_id'];
$password = md5($form_data['password']);

$this->db->where('id',$id);
// notice the mistake I just made: instead of $user_id, I used $id that has not yet been
// initialized or declared.

$this->db->update('users',array('password'=>$password));

What I will end up doing here is update the password field of all records in the table. So, fellow CodeIgniters beware when making update and delete operations like these.


Messages In This Thread
Active Record gotcha - by El Forum - 10-22-2007, 09:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB