codeigniter unique check on editing a field

function unique_check($str, $field,$exclude=''){   list($table, $field) = explode('.', $field);   if(!empty($exclude)){      list($field_name, $value) = explode('.', $exclude);      $this->db->where_not_in($field_name,$value);   }

   if (isset($this->db))   {      $query = $this->db->limit(1)->get_where($table, array($field => $str));      return $query->num_rows() === 0;   }
   return FALSE;}

$this->unique_check('test@domain.com','tablename.coloum_name','coloum_name.coloum_value');

Comments

Popular posts from this blog

Enable the imap in support in xampp server