<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Contacts_model extends App_Model
{
    public function __construct()
    {
        parent::__construct();
        $this->load->database();
    }
    public function getEmail($email){
        $this->db->select('*'); // Select all columns
        $this->db->from(db_prefix() . 'contacts'); // Specify the table name

        // Define your WHERE conditions
        $this->db->where('email', $email);
        $this->db->where('role', 'client');
        $this->db->where('is_primary', '1');

        // Get the results
        $query = $this->db->get();
        if($query->num_rows() > 0){
            return $query->result();
        }else{
            $this->db->select('*'); // Select all columns
            $this->db->from(db_prefix() . 'staff'); // Specify the table name
        // Define your WHERE conditions
        $this->db->where('email', $email);

        // Get the results
        $query = $this->db->get();
        return $query->result();
        }
        
    } 
   
}
