<?php
/**
 *	Generated by miceCMS
 *	Date: 2010-11-18 10:50:22
 */
class model_Pollcategory {
	private $subsection="";
	private $setstr="";
	private $fields="";
	private $values="";
	private $nrows="";
	private $offset="";
	private $pages=10;
	private $pagenum=1;
	private $pollcategoryId=Null;		//	 field type: "int(11+int)"
	private $title=Null;		//	 field type: "varchar(255+varchar)"
	private $content=Null;		//	 field type: "text(+text)"
	private $usergroupId=0;		//	 field type: "int(11+int)"
	private $checks=1;		//	 field type: "int(11+int)"
	private $times=0;		//	 field type: "int(11+int)"
	private $startdate=0;		//	 field type: "int(11+int)"
	private $stopdate=0;		//	 field type: "int(11+int)"
	private $isvisible=0;		//	 field type: "int(11+int)"
	private $isopen=0;		//	 field type: "int(11+int)"
	private $userId=0;		//	 field type: "int(11+int)"
	private $ip=Null;		//	 field type: "varchar(100+varchar)"
	private $num=0;		//	 field type: "int(11+int)"
	private $pointnum=0;		//	 field type: "int(11+int)"

	public function getPollcategoryId(){
		return $this->pollcategoryId;
	}
	public function setPollcategoryId($pollcategoryId){
		$this->pollcategoryId=$pollcategoryId;
		if($this->setstr=="")
			$this->setstr="pollcategory_id=".$pollcategoryId."";
		else
			$this->setstr.=",pollcategory_id=".$pollcategoryId."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="pollcategory_id";
			$this->values="".$pollcategoryId."";
		}else{
			$this->fields.=",pollcategory_id";
			$this->values.=",".$pollcategoryId."";
		}
	}
	public function getTitle(){
		return $this->title;
	}
	public function setTitle($title){
		$this->title=$title;
		if($this->setstr=="")
			$this->setstr="title='".$title."'";
		else
			$this->setstr.=",title='".$title."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="title";
			$this->values="'".$title."'";
		}else{
			$this->fields.=",title";
			$this->values.=",'".$title."'";
		}
	}
	public function getContent(){
		return $this->content;
	}
	public function setContent($content){
		$this->content=$content;
		if($this->setstr=="")
			$this->setstr="content='".$content."'";
		else
			$this->setstr.=",content='".$content."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="content";
			$this->values="'".$content."'";
		}else{
			$this->fields.=",content";
			$this->values.=",'".$content."'";
		}
	}
	public function getUsergroupId(){
		return $this->usergroupId;
	}
	public function setUsergroupId($usergroupId){
		$this->usergroupId=$usergroupId;
		if($this->setstr=="")
			$this->setstr="usergroup_id=".$usergroupId."";
		else
			$this->setstr.=",usergroup_id=".$usergroupId."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="usergroup_id";
			$this->values="".$usergroupId."";
		}else{
			$this->fields.=",usergroup_id";
			$this->values.=",".$usergroupId."";
		}
	}
	public function getChecks(){
		return $this->checks;
	}
	public function setChecks($checks){
		$this->checks=$checks;
		if($this->setstr=="")
			$this->setstr="checks=".$checks."";
		else
			$this->setstr.=",checks=".$checks."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="checks";
			$this->values="".$checks."";
		}else{
			$this->fields.=",checks";
			$this->values.=",".$checks."";
		}
	}
	public function getTimes(){
		return $this->times;
	}
	public function setTimes($times){
		$this->times=$times;
		if($this->setstr=="")
			$this->setstr="times=".$times."";
		else
			$this->setstr.=",times=".$times."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="times";
			$this->values="".$times."";
		}else{
			$this->fields.=",times";
			$this->values.=",".$times."";
		}
	}
	public function getStartdate(){
		return $this->startdate;
	}
	public function setStartdate($startdate){
		$this->startdate=$startdate;
		if($this->setstr=="")
			$this->setstr="startdate=".$startdate."";
		else
			$this->setstr.=",startdate=".$startdate."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="startdate";
			$this->values="".$startdate."";
		}else{
			$this->fields.=",startdate";
			$this->values.=",".$startdate."";
		}
	}
	public function getStopdate(){
		return $this->stopdate;
	}
	public function setStopdate($stopdate){
		$this->stopdate=$stopdate;
		if($this->setstr=="")
			$this->setstr="stopdate=".$stopdate."";
		else
			$this->setstr.=",stopdate=".$stopdate."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="stopdate";
			$this->values="".$stopdate."";
		}else{
			$this->fields.=",stopdate";
			$this->values.=",".$stopdate."";
		}
	}
	public function getIsvisible(){
		return $this->isvisible;
	}
	public function setIsvisible($isvisible){
		$this->isvisible=$isvisible;
		if($this->setstr=="")
			$this->setstr="isvisible=".$isvisible."";
		else
			$this->setstr.=",isvisible=".$isvisible."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="isvisible";
			$this->values="".$isvisible."";
		}else{
			$this->fields.=",isvisible";
			$this->values.=",".$isvisible."";
		}
	}
	public function getIsopen(){
		return $this->isopen;
	}
	public function setIsopen($isopen){
		$this->isopen=$isopen;
		if($this->setstr=="")
			$this->setstr="isopen=".$isopen."";
		else
			$this->setstr.=",isopen=".$isopen."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="isopen";
			$this->values="".$isopen."";
		}else{
			$this->fields.=",isopen";
			$this->values.=",".$isopen."";
		}
	}
	public function getUserId(){
		return $this->userId;
	}
	public function setUserId($userId){
		$this->userId=$userId;
		if($this->setstr=="")
			$this->setstr="user_id=".$userId."";
		else
			$this->setstr.=",user_id=".$userId."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="user_id";
			$this->values="".$userId."";
		}else{
			$this->fields.=",user_id";
			$this->values.=",".$userId."";
		}
	}
	public function getIp(){
		return $this->ip;
	}
	public function setIp($ip){
		$this->ip=$ip;
		if($this->setstr=="")
			$this->setstr="ip='".$ip."'";
		else
			$this->setstr.=",ip='".$ip."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="ip";
			$this->values="'".$ip."'";
		}else{
			$this->fields.=",ip";
			$this->values.=",'".$ip."'";
		}
	}
	public function getNum(){
		return $this->num;
	}
	public function setNum($num){
		$this->num=$num;
		if($this->setstr=="")
			$this->setstr="num=".$num."";
		else
			$this->setstr.=",num=".$num."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="num";
			$this->values="".$num."";
		}else{
			$this->fields.=",num";
			$this->values.=",".$num."";
		}
	}
	public function getPointnum(){
		return $this->pointnum;
	}
	public function setPointnum($pointnum){
		$this->pointnum=$pointnum;
		if($this->setstr=="")
			$this->setstr="pointnum=".$pointnum."";
		else
			$this->setstr.=",pointnum=".$pointnum."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="pointnum";
			$this->values="".$pointnum."";
		}else{
			$this->fields.=",pointnum";
			$this->values.=",".$pointnum."";
		}
	}
	public function setSubsection($str){
		$this->subsection=" ".$str;
	}
	public function setNrows($str){
		$this->nrows=$str;
	}
	public function setOffset($str){
		$this->offset=$str;
	}
	public function setPages($str){
		$this->pages=$str;
	}
	public function setPagenum($str){
		$this->pagenum=$str;
	}
	public function doSelect() {
		global $conn;
		$result=$conn->SelectArray("#__pollcategory ","*",$this->subsection);
		return $this->fetchResult($result);
	}
	public function doSelectLimit() {
		global $conn;
		$result=$conn->SelectArrayLimit("#__pollcategory ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResult($result);
	}
	public function doSelectOne() {
		global $conn;
		$result=$conn->SelectRow("#__pollcategory ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResultOne($result);
	}
	public function doCount() {
		global $conn;
		return $conn->SelectCount("#__pollcategory ","*",$this->subsection);
	}
	public function doInsert() {
		global $conn;
		return $conn->Insert("#__pollcategory ",$this->fields,$this->values);
	}
	public function doDelete() {
		global $conn;
		return $conn->Delete("#__pollcategory ",$this->subsection);
	}
	public function doUpdate() {
		global $conn;
		return $conn->Update("#__pollcategory ",$this->setstr,$this->subsection);
	}
	public function Pager() {
		$this->nrows=($this->pagenum-1)*$this->pages;
		$this->offset=$this->pages;
		return $this->doSelectLimit();
	}
	public function Page() {
		return $this->pagenum;
	}
	public function Totals() {
		return $this->doCount();
	}
	public function TotalPages() {
		if (!$this->doCount())	return 0;
		return (int)ceil($this->Totals()/$this->pages);
	}
	public function fetchResult($result){
		if(!$result){
			return $result;
		}
		$array=new ArrayObject();
		for($i=0;$i<count($result);$i++){
			$pollcategory=new model_Pollcategory();
			$pollcategory->pollcategoryId=$result[$i]["pollcategory_id"];
			$pollcategory->title=$result[$i]["title"];
			$pollcategory->content=$result[$i]["content"];
			$pollcategory->usergroupId=$result[$i]["usergroup_id"];
			$pollcategory->checks=$result[$i]["checks"];
			$pollcategory->times=$result[$i]["times"];
			$pollcategory->startdate=$result[$i]["startdate"];
			$pollcategory->stopdate=$result[$i]["stopdate"];
			$pollcategory->isvisible=$result[$i]["isvisible"];
			$pollcategory->isopen=$result[$i]["isopen"];
			$pollcategory->userId=$result[$i]["user_id"];
			$pollcategory->ip=$result[$i]["ip"];
			$pollcategory->num=$result[$i]["num"];
			$pollcategory->pointnum=$result[$i]["pointnum"];
			$array->append($pollcategory);
		}
		return $array;
	}
	public function fetchResultOne($result){
		if(!$result){
			return $result;
		}
		$pollcategory=new model_Pollcategory();
		$pollcategory->pollcategoryId=$result["pollcategory_id"];
		$pollcategory->title=$result["title"];
		$pollcategory->content=$result["content"];
		$pollcategory->usergroupId=$result["usergroup_id"];
		$pollcategory->checks=$result["checks"];
		$pollcategory->times=$result["times"];
		$pollcategory->startdate=$result["startdate"];
		$pollcategory->stopdate=$result["stopdate"];
		$pollcategory->isvisible=$result["isvisible"];
		$pollcategory->isopen=$result["isopen"];
		$pollcategory->userId=$result["user_id"];
		$pollcategory->ip=$result["ip"];
		$pollcategory->num=$result["num"];
		$pollcategory->pointnum=$result["pointnum"];
		return $pollcategory;
	}
}
?>