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

class Dashboard_Model extends CI_Model
{
    
    /**
     * This function used to check the login credentials of the user
     * @param string $email : This is email of the user
     * @param string $password : This is encrypted password of the user
     */
    function Count_Users()
    {
        $query = $this->db->get('users');
        
       if($query->num_rows()>0)
       {
            return $query->num_rows();
       }

       else
       {
           return false;
       }
    }

    function Count_Titles()
    {
        $query = $this->db->get('ballot');
        
       if($query->num_rows()>0)
       {
            return $query->num_rows();
       }

       else
       {
           return false;
       }
    }

    function Count_Candidates()
    {
        $query = $this->db->get('participants');
        
       if($query->num_rows()>0)
       {
            return $query->num_rows();
       }

       else
       {
           return false;
       }
    }

    function Count_Votes()
    {
        $query = $this->db->select_sum('vote')->from('participants')->get();
        
       if($query->num_rows()>0)
       {
            return ($query->result()[0]->vote) ;
       }

       else
       {
           return false;
       }
    }
    
    function Fetch_Ballot_Data()
    {
        $query = $this->db->select('*')->from('ballot')->get();
       

       if($query->num_rows()>0)
       {
             return $query->result();
       }

       else
       {
           return false;
       }
    }

}

?>
