<?php
/**
 *	Generated by miceCMS
 *	Date: 2010-11-18 10:50:22
 */
class model_Plugin {
	private $subsection="";
	private $setstr="";
	private $fields="";
	private $values="";
	private $nrows="";
	private $offset="";
	private $pages=10;
	private $pagenum=1;
	private $pluginId=Null;		//	 field type: "int(11+int)"
	private $hook=Null;		//	 field type: "varchar(255+varchar)"
	private $name=Null;		//	 field type: "varchar(255+varchar)"
	private $orderid=0;		//	 field type: "int(11+int)"
	private $isopen=0;		//	 field type: "int(11+int)"

	public function getPluginId(){
		return $this->pluginId;
	}
	public function setPluginId($pluginId){
		$this->pluginId=$pluginId;
		if($this->setstr=="")
			$this->setstr="plugin_id=".$pluginId."";
		else
			$this->setstr.=",plugin_id=".$pluginId."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="plugin_id";
			$this->values="".$pluginId."";
		}else{
			$this->fields.=",plugin_id";
			$this->values.=",".$pluginId."";
		}
	}
	public function getHook(){
		return $this->hook;
	}
	public function setHook($hook){
		$this->hook=$hook;
		if($this->setstr=="")
			$this->setstr="hook='".$hook."'";
		else
			$this->setstr.=",hook='".$hook."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="hook";
			$this->values="'".$hook."'";
		}else{
			$this->fields.=",hook";
			$this->values.=",'".$hook."'";
		}
	}
	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 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 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 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("#__plugin ","*",$this->subsection);
		return $this->fetchResult($result);
	}
	public function doSelectLimit() {
		global $conn;
		$result=$conn->SelectArrayLimit("#__plugin ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResult($result);
	}
	public function doSelectOne() {
		global $conn;
		$result=$conn->SelectRow("#__plugin ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResultOne($result);
	}
	public function doCount() {
		global $conn;
		return $conn->SelectCount("#__plugin ","*",$this->subsection);
	}
	public function doInsert() {
		global $conn;
		return $conn->Insert("#__plugin ",$this->fields,$this->values);
	}
	public function doDelete() {
		global $conn;
		return $conn->Delete("#__plugin ",$this->subsection);
	}
	public function doUpdate() {
		global $conn;
		return $conn->Update("#__plugin ",$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++){
			$plugin=new model_Plugin();
			$plugin->pluginId=$result[$i]["plugin_id"];
			$plugin->hook=$result[$i]["hook"];
			$plugin->name=$result[$i]["name"];
			$plugin->orderid=$result[$i]["orderid"];
			$plugin->isopen=$result[$i]["isopen"];
			$array->append($plugin);
		}
		return $array;
	}
	public function fetchResultOne($result){
		if(!$result){
			return $result;
		}
		$plugin=new model_Plugin();
		$plugin->pluginId=$result["plugin_id"];
		$plugin->hook=$result["hook"];
		$plugin->name=$result["name"];
		$plugin->orderid=$result["orderid"];
		$plugin->isopen=$result["isopen"];
		return $plugin;
	}
}
?>