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
Post a Comment