Welcome Guest, Not a member yet? Register   Sign In
basic but....
#14

[eluser]xwero[/eluser]
If you put this in CI model code a method would look like this (in a primitive state)
Code:
function update_user($where,$custom_fieldnames = array(),$custom_val_rules = array())
{
   $post['first_name'] = $_POST['first_name'];
   // ...
   $this->change_post_value($post,$custom_fieldnames)
   // array('given_name'=>array('first_name','Given name')) will change the $post['first_name'] value
   if(isset($post['first_name']))
   {
      $rules['first_name'] = $this->change_rule('first_name','alpha',$custom_val_rules);
      // array('first_name','required|alpha') would change the rule
      $fields['first_name'] = $this->change_error('first_name','First name',$custom_fieldnames);
      $this->db->set('first_name',$post['first_name']);
   }
   // ...
   $this->validation->set_rules($rules);
   $this->validation->set_fields($fields);
   if(!$this->validation->run())
   {
       return $this->validation->error_string;
   }
   else
   {
      $this->db->where($where);
      $this->db->update('users');
      return $this->affected_rows();
   }
}


Messages In This Thread
basic but.... - by El Forum - 03-11-2008, 11:46 AM
basic but.... - by El Forum - 03-11-2008, 11:57 AM
basic but.... - by El Forum - 03-11-2008, 04:24 PM
basic but.... - by El Forum - 03-12-2008, 03:30 AM
basic but.... - by El Forum - 03-12-2008, 03:41 AM
basic but.... - by El Forum - 03-12-2008, 04:36 AM
basic but.... - by El Forum - 03-12-2008, 04:39 AM
basic but.... - by El Forum - 03-12-2008, 05:00 AM
basic but.... - by El Forum - 03-12-2008, 06:30 AM
basic but.... - by El Forum - 03-12-2008, 06:55 AM
basic but.... - by El Forum - 03-13-2008, 02:25 AM
basic but.... - by El Forum - 03-13-2008, 02:58 AM
basic but.... - by El Forum - 03-13-2008, 04:11 AM
basic but.... - by El Forum - 03-13-2008, 05:04 AM
basic but.... - by El Forum - 03-13-2008, 06:13 AM
basic but.... - by El Forum - 03-13-2008, 06:41 AM
basic but.... - by El Forum - 03-13-2008, 07:12 AM
basic but.... - by El Forum - 03-13-2008, 02:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB