php - Having trouble with Codeigniter library -


i working codeigniter library called my_model.php in model there following function,

public function update($primary_value, $data, $skip_validation = false) {     $valid = true;     if($skip_validation === false)     {         $valid = $this->_run_validation($data);     }      if($valid)     {         $this->skip_validation = false;         return $this->db->where($this->primary_key, $primary_value)             ->set($data)             ->update($this->_table);     }     else     {         return false;     } } 

i executing function following code,

$update = array('last_logged_in', date("y-m-d h:i:s"));             if($this->ci->users_model->update($query[0]['user_id'], array('last_logged_in', date("y-m-d h:i:s"))))             {                 $this->session->set_flashdata('success', 'you have been logged in');                 switch($query['user_type_id'])                 {                     case 1:                         redirect('/candidate/dashboard');                         break;                      case 2:                         redirect('/employer/dashboard');                         break;                      case 3:                         redirect('/admin/dashboard');                         break;                 }             } 

however getting following errors,

a database error occurred

error number: 1054

unknown column '0' in 'field list'

update users set 0 = 'last_logged_in', 1 = '2011-04-28 21:06:51' user_id = '2'

try changing

array('last_logged_in', date("y-m-d h:i:s")) 

to

array('last_logged_in' => date("y-m-d h:i:s")) 

Comments