<?php
/**
 *	Generated by miceCMS
 *	Date: 2010-11-18 10:50:22
 */
class model_Filecategory {
	private $subsection="";
	private $setstr="";
	private $fields="";
	private $values="";
	private $nrows="";
	private $offset="";
	private $pages=10;
	private $pagenum=1;
	private $filecategoryId=Null;		//	 field type: "int(11+int)"
	private $title=Null;		//	 field type: "varchar(50+varchar)"
	private $parentid=0;		//	 field type: "int(11+int)"
	private $path=Null;		//	 field type: "varchar(255+varchar)"
	private $orderid=0;		//	 field type: "int(11+int)"
	private $depth=0;		//	 field type: "int(11+int)"
	private $childcount=0;		//	 field type: "int(11+int)"
	private $summary=Null;		//	 field type: "varchar(255+varchar)"
	private $type=Null;		//	 field type: "varchar(200+varchar)"

	public function getFilecategoryId(){
		return $this->filecategoryId;
	}
	public function setFilecategoryId($filecategoryId){
		$this->filecategoryId=$filecategoryId;
		if($this->setstr=="")
			$this->setstr="filecategory_id=".$filecategoryId."";
		else
			$this->setstr.=",filecategory_id=".$filecategoryId."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="filecategory_id";
			$this->values="".$filecategoryId."";
		}else{
			$this->fields.=",filecategory_id";
			$this->values.=",".$filecategoryId."";
		}
	}
	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 getPath(){
		return $this->path;
	}
	public function setPath($path){
		$this->path=$path;
		if($this->setstr=="")
			$this->setstr="path='".$path."'";
		else
			$this->setstr.=",path='".$path."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="path";
			$this->values="'".$path."'";
		}else{
			$this->fields.=",path";
			$this->values.=",'".$path."'";
		}
	}
	public function getOrderid(){
		return $this->orderid;
	}
	public function setOrderid($orderid){
		$this->orderid=$orderid;
		if($this->setstr=="")
			$this->setstr="orderid=".$orderid."";
		else
			$this->setstr.=",orderid=".$orderid."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="orderid";
			$this->values="".$orderid."";
		}else{
			$this->fields.=",orderid";
			$this->values.=",".$orderid."";
		}
	}
	public function getDepth(){
		return $this->depth;
	}
	public function setDepth($depth){
		$this->depth=$depth;
		if($this->setstr=="")
			$this->setstr="depth=".$depth."";
		else
			$this->setstr.=",depth=".$depth."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="depth";
			$this->values="".$depth."";
		}else{
			$this->fields.=",depth";
			$this->values.=",".$depth."";
		}
	}
	public function getChildcount(){
		return $this->childcount;
	}
	public function setChildcount($childcount){
		$this->childcount=$childcount;
		if($this->setstr=="")
			$this->setstr="childcount=".$childcount."";
		else
			$this->setstr.=",childcount=".$childcount."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="childcount";
			$this->values="".$childcount."";
		}else{
			$this->fields.=",childcount";
			$this->values.=",".$childcount."";
		}
	}
	public function getSummary(){
		return $this->summary;
	}
	public function setSummary($summary){
		$this->summary=$summary;
		if($this->setstr=="")
			$this->setstr="summary='".$summary."'";
		else
			$this->setstr.=",summary='".$summary."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="summary";
			$this->values="'".$summary."'";
		}else{
			$this->fields.=",summary";
			$this->values.=",'".$summary."'";
		}
	}
	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 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("#__filecategory ","*",$this->subsection);
		return $this->fetchResult($result);
	}
	public function doSelectLimit() {
		global $conn;
		$result=$conn->SelectArrayLimit("#__filecategory ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResult($result);
	}
	public function doSelectOne() {
		global $conn;
		$result=$conn->SelectRow("#__filecategory ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResultOne($result);
	}
	public function doCount() {
		global $conn;
		return $conn->SelectCount("#__filecategory ","*",$this->subsection);
	}
	public function doInsert() {
		global $conn;
		return $conn->Insert("#__filecategory ",$this->fields,$this->values);
	}
	public function doDelete() {
		global $conn;
		return $conn->Delete("#__filecategory ",$this->subsection);
	}
	public function doUpdate() {
		global $conn;
		return $conn->Update("#__filecategory ",$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++){
			$filecategory=new model_Filecategory();
			$filecategory->filecategoryId=$result[$i]["filecategory_id"];
			$filecategory->title=$result[$i]["title"];
			$filecategory->parentid=$result[$i]["parentid"];
			$filecategory->path=$result[$i]["path"];
			$filecategory->orderid=$result[$i]["orderid"];
			$filecategory->depth=$result[$i]["depth"];
			$filecategory->childcount=$result[$i]["childcount"];
			$filecategory->summary=$result[$i]["summary"];
			$filecategory->type=$result[$i]["type"];
			$array->append($filecategory);
		}
		return $array;
	}
	public function fetchResultOne($result){
		if(!$result){
			return $result;
		}
		$filecategory=new model_Filecategory();
		$filecategory->filecategoryId=$result["filecategory_id"];
		$filecategory->title=$result["title"];
		$filecategory->parentid=$result["parentid"];
		$filecategory->path=$result["path"];
		$filecategory->orderid=$result["orderid"];
		$filecategory->depth=$result["depth"];
		$filecategory->childcount=$result["childcount"];
		$filecategory->summary=$result["summary"];
		$filecategory->type=$result["type"];
		return $filecategory;
	}
}
?>