


<head>


<meta content="text/html; charset=utf-8" http-equiv="Content-Type">


</head>





<?php 


class polls_model extends CI_model


 {


   


     function get_all_polls()


		{


		$this->db->order_by("id", "desc");


		$qry =$this->db->get('poll');	


		if($qry->num_rows() > 0)


		     return $qry ;   


		     return FALSE; 


		}








	





	function add_poll_ans($data)


	{


	             $q=$this->db->insert('poll_user',$data);


	             if($q)


	             {


	             echo "تم التصويت بنجاح شكرا لك";


	             }


	





    }	


    


    


    


    function get_poll()


		{


		$this->db->order_by("id", "desc");


		$qry =$this->db->get('poll',1);	


		if($qry->num_rows() > 0)


		     return $qry ;   


		     return FALSE; 


		}








      function get_poll_answer($pollid)


		{


		$this->db->where('pollid',$pollid);


		$qry =$this->db->get('poll_answer');	


		if($qry->num_rows() > 0)


		     return $qry ;   


		     return FALSE; 


		}


		


		


      function get_poll_answer_count($pollid)


		{


		$this->db->where('pollid',$pollid);


		$qry =$this->db->get('poll_user');	


		return $qry->num_rows() ;   


		}


		


		


		function get_answer_visitors_count($ansid)


		{


		$this->db->where('answerid',$ansid);


		$qry =$this->db->get('poll_user');	


		return $qry->num_rows() ;   


		}

















			





}


