<?php
/**
 *	Generated by miceCMS
 *	Date: 2010-11-18 10:50:22
 */
class model_Config {
	private $subsection="";
	private $setstr="";
	private $fields="";
	private $values="";
	private $nrows="";
	private $offset="";
	private $pages=10;
	private $pagenum=1;
	private $configId=Null;		//	 field type: "int(11+int)"
	private $value=Null;		//	 field type: "varchar(255+varchar)"
	private $tag=Null;		//	 field type: "varchar(255+varchar)"
	private $addedvalue=Null;		//	 field type: "text(+text)"
	private $isuse=0;		//	 field type: "int(11+int)"
	private $intro=Null;		//	 field type: "varchar(255+varchar)"

	public function getConfigId(){
		return $this->configId;
	}
	public function setConfigId($configId){
		$this->configId=$configId;
		if($this->setstr=="")
			$this->setstr="config_id=".$configId."";
		else
			$this->setstr.=",config_id=".$configId."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="config_id";
			$this->values="".$configId."";
		}else{
			$this->fields.=",config_id";
			$this->values.=",".$configId."";
		}
	}
	public function getValue(){
		return $this->value;
	}
	public function setValue($value){
		$this->value=$value;
		if($this->setstr=="")
			$this->setstr="value='".$value."'";
		else
			$this->setstr.=",value='".$value."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="value";
			$this->values="'".$value."'";
		}else{
			$this->fields.=",value";
			$this->values.=",'".$value."'";
		}
	}
	public function getTag(){
		return $this->tag;
	}
	public function setTag($tag){
		$this->tag=$tag;
		if($this->setstr=="")
			$this->setstr="tag='".$tag."'";
		else
			$this->setstr.=",tag='".$tag."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="tag";
			$this->values="'".$tag."'";
		}else{
			$this->fields.=",tag";
			$this->values.=",'".$tag."'";
		}
	}
	public function getAddedvalue(){
		return $this->addedvalue;
	}
	public function setAddedvalue($addedvalue){
		$this->addedvalue=$addedvalue;
		if($this->setstr=="")
			$this->setstr="addedvalue='".$addedvalue."'";
		else
			$this->setstr.=",addedvalue='".$addedvalue."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="addedvalue";
			$this->values="'".$addedvalue."'";
		}else{
			$this->fields.=",addedvalue";
			$this->values.=",'".$addedvalue."'";
		}
	}
	public function getIsuse(){
		return $this->isuse;
	}
	public function setIsuse($isuse){
		$this->isuse=$isuse;
		if($this->setstr=="")
			$this->setstr="isuse=".$isuse."";
		else
			$this->setstr.=",isuse=".$isuse."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="isuse";
			$this->values="".$isuse."";
		}else{
			$this->fields.=",isuse";
			$this->values.=",".$isuse."";
		}
	}
	public function getIntro(){
		return $this->intro;
	}
	public function setIntro($intro){
		$this->intro=$intro;
		if($this->setstr=="")
			$this->setstr="intro='".$intro."'";
		else
			$this->setstr.=",intro='".$intro."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="intro";
			$this->values="'".$intro."'";
		}else{
			$this->fields.=",intro";
			$this->values.=",'".$intro."'";
		}
	}
	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("#__config ","*",$this->subsection);
		return $this->fetchResult($result);
	}
	public function doSelectLimit() {
		global $conn;
		$result=$conn->SelectArrayLimit("#__config ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResult($result);
	}
	public function doSelectOne() {
		global $conn;
		$result=$conn->SelectRow("#__config ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResultOne($result);
	}
	public function doCount() {
		global $conn;
		return $conn->SelectCount("#__config ","*",$this->subsection);
	}
	public function doInsert() {
		global $conn;
		return $conn->Insert("#__config ",$this->fields,$this->values);
	}
	public function doDelete() {
		global $conn;
		return $conn->Delete("#__config ",$this->subsection);
	}
	public function doUpdate() {
		global $conn;
		return $conn->Update("#__config ",$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++){
			$config=new model_Config();
			$config->configId=$result[$i]["config_id"];
			$config->value=$result[$i]["value"];
			$config->tag=$result[$i]["tag"];
			$config->addedvalue=$result[$i]["addedvalue"];
			$config->isuse=$result[$i]["isuse"];
			$config->intro=$result[$i]["intro"];
			$array->append($config);
		}
		return $array;
	}
	public function fetchResultOne($result){
		if(!$result){
			return $result;
		}
		$config=new model_Config();
		$config->configId=$result["config_id"];
		$config->value=$result["value"];
		$config->tag=$result["tag"];
		$config->addedvalue=$result["addedvalue"];
		$config->isuse=$result["isuse"];
		$config->intro=$result["intro"];
		return $config;
	}
}
?>