<?php
/**
 *	Generated by miceCMS
 *	Date: 2010-11-18 10:50:22
 */
class model_Form {
	private $subsection="";
	private $setstr="";
	private $fields="";
	private $values="";
	private $nrows="";
	private $offset="";
	private $pages=10;
	private $pagenum=1;
	private $formId=Null;		//	 field type: "int(11+int)"
	private $name=Null;		//	 field type: "varchar(100+varchar)"
	private $email=Null;		//	 field type: "varchar(255+varchar)"
	private $title=Null;		//	 field type: "varchar(255+varchar)"
	private $parentid=0;		//	 field type: "int(11+int)"
	private $userId=0;		//	 field type: "int(11+int)"
	private $type=Null;		//	 field type: "varchar(255+varchar)"
	private $createdat=0;		//	 field type: "int(11+int)"
	private $ip=Null;		//	 field type: "varchar(100+varchar)"
	private $content=Null;		//	 field type: "text(+text)"
	private $isopen=0;		//	 field type: "int(11+int)"
	private $isview=0;		//	 field type: "int(11+int)"
	private $re=Null;		//	 field type: "text(+text)"

	public function getFormId(){
		return $this->formId;
	}
	public function setFormId($formId){
		$this->formId=$formId;
		if($this->setstr=="")
			$this->setstr="form_id=".$formId."";
		else
			$this->setstr.=",form_id=".$formId."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="form_id";
			$this->values="".$formId."";
		}else{
			$this->fields.=",form_id";
			$this->values.=",".$formId."";
		}
	}
	public function getName(){
		return $this->name;
	}
	public function setName($name){
		$this->name=$name;
		if($this->setstr=="")
			$this->setstr="name='".$name."'";
		else
			$this->setstr.=",name='".$name."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="name";
			$this->values="'".$name."'";
		}else{
			$this->fields.=",name";
			$this->values.=",'".$name."'";
		}
	}
	public function getEmail(){
		return $this->email;
	}
	public function setEmail($email){
		$this->email=$email;
		if($this->setstr=="")
			$this->setstr="email='".$email."'";
		else
			$this->setstr.=",email='".$email."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="email";
			$this->values="'".$email."'";
		}else{
			$this->fields.=",email";
			$this->values.=",'".$email."'";
		}
	}
	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 getParentid(){
		return $this->parentid;
	}
	public function setParentid($parentid){
		$this->parentid=$parentid;
		if($this->setstr=="")
			$this->setstr="parentid=".$parentid."";
		else
			$this->setstr.=",parentid=".$parentid."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="parentid";
			$this->values="".$parentid."";
		}else{
			$this->fields.=",parentid";
			$this->values.=",".$parentid."";
		}
	}
	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 getType(){
		return $this->type;
	}
	public function setType($type){
		$this->type=$type;
		if($this->setstr=="")
			$this->setstr="type='".$type."'";
		else
			$this->setstr.=",type='".$type."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="type";
			$this->values="'".$type."'";
		}else{
			$this->fields.=",type";
			$this->values.=",'".$type."'";
		}
	}
	public function getCreatedat(){
		return $this->createdat;
	}
	public function setCreatedat($createdat){
		$this->createdat=$createdat;
		if($this->setstr=="")
			$this->setstr="createdat=".$createdat."";
		else
			$this->setstr.=",createdat=".$createdat."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="createdat";
			$this->values="".$createdat."";
		}else{
			$this->fields.=",createdat";
			$this->values.=",".$createdat."";
		}
	}
	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 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 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 getIsview(){
		return $this->isview;
	}
	public function setIsview($isview){
		$this->isview=$isview;
		if($this->setstr=="")
			$this->setstr="isview=".$isview."";
		else
			$this->setstr.=",isview=".$isview."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="isview";
			$this->values="".$isview."";
		}else{
			$this->fields.=",isview";
			$this->values.=",".$isview."";
		}
	}
	public function getRe(){
		return $this->re;
	}
	public function setRe($re){
		$this->re=$re;
		if($this->setstr=="")
			$this->setstr="re='".$re."'";
		else
			$this->setstr.=",re='".$re."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="re";
			$this->values="'".$re."'";
		}else{
			$this->fields.=",re";
			$this->values.=",'".$re."'";
		}
	}
	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("#__form ","*",$this->subsection);
		return $this->fetchResult($result);
	}
	public function doSelectLimit() {
		global $conn;
		$result=$conn->SelectArrayLimit("#__form ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResult($result);
	}
	public function doSelectOne() {
		global $conn;
		$result=$conn->SelectRow("#__form ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResultOne($result);
	}
	public function doCount() {
		global $conn;
		return $conn->SelectCount("#__form ","*",$this->subsection);
	}
	public function doInsert() {
		global $conn;
		return $conn->Insert("#__form ",$this->fields,$this->values);
	}
	public function doDelete() {
		global $conn;
		return $conn->Delete("#__form ",$this->subsection);
	}
	public function doUpdate() {
		global $conn;
		return $conn->Update("#__form ",$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++){
			$form=new model_Form();
			$form->formId=$result[$i]["form_id"];
			$form->name=$result[$i]["name"];
			$form->email=$result[$i]["email"];
			$form->title=$result[$i]["title"];
			$form->parentid=$result[$i]["parentid"];
			$form->userId=$result[$i]["user_id"];
			$form->type=$result[$i]["type"];
			$form->createdat=$result[$i]["createdat"];
			$form->ip=$result[$i]["ip"];
			$form->content=$result[$i]["content"];
			$form->isopen=$result[$i]["isopen"];
			$form->isview=$result[$i]["isview"];
			$form->re=$result[$i]["re"];
			$array->append($form);
		}
		return $array;
	}
	public function fetchResultOne($result){
		if(!$result){
			return $result;
		}
		$form=new model_Form();
		$form->formId=$result["form_id"];
		$form->name=$result["name"];
		$form->email=$result["email"];
		$form->title=$result["title"];
		$form->parentid=$result["parentid"];
		$form->userId=$result["user_id"];
		$form->type=$result["type"];
		$form->createdat=$result["createdat"];
		$form->ip=$result["ip"];
		$form->content=$result["content"];
		$form->isopen=$result["isopen"];
		$form->isview=$result["isview"];
		$form->re=$result["re"];
		return $form;
	}
}
?>