I am working on a site in codeigniter.I am not so expert using framework.Here I have to check if email already exists in database.I have coded the required functionality but
Just add is_unique[tablename.fieldname]
rules to the form validation. for Example:
array('field' => 'email', 'label' => 'Email', 'rules' => 'trim|required|valid_email|is_unique[users.email]'));
Your Model is like
$this->db->select('id');
$this->db->where('email', $email);
please tell the mysql from which table you want to get the record.
$this->db->from('tablename');
it would be like
$this->db->select('id');
$this->db->from('tablename');
$this->db->where('email', $email);