<?php
/**
 *	Generated by miceCMS
 *	Date: 2010-11-18 10:50:22
 */
class model_Link {
	private $subsection="";
	private $setstr="";
	private $fields="";
	private $values="";
	private $nrows="";
	private $offset="";
	private $pages=10;
	private $pagenum=1;
	private $linkId=Null;		//	 field type: "int(11+int)"
	private $categoryId=Null;		//	 field type: "varchar(255+varchar)"
	private $userId=0;		//	 field type: "int(11+int)"
	private $orderid=0;		//	 field type: "int(11+int)"
	private $title=Null;		//	 field type: "varchar(255+varchar)"
	private $url=Null;		//	 field type: "varchar(255+varchar)"
	private $logo=Null;		//	 field type: "varchar(255+varchar)"
	private $summary=Null;		//	 field type: "varchar(255+varchar)"

	public function getLinkId(){
		return $this->linkId;
	}
	public function setLinkId($linkId){
		$this->linkId=$linkId;
		if($this->setstr=="")
			$this->setstr="link_id=".$linkId."";
		else
			$this->setstr.=",link_id=".$linkId."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="link_id";
			$this->values="".$linkId."";
		}else{
			$this->fields.=",link_id";
			$this->values.=",".$linkId."";
		}
	}
	public function getCategoryId(){
		return $this->categoryId;
	}
	public function setCategoryId($categoryId){
		$this->categoryId=$categoryId;
		if($this->setstr=="")
			$this->setstr="category_id='".$categoryId."'";
		else
			$this->setstr.=",category_id='".$categoryId."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="category_id";
			$this->values="'".$categoryId."'";
		}else{
			$this->fields.=",category_id";
			$this->values.=",'".$categoryId."'";
		}
	}
	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 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 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 getUrl(){
		return $this->url;
	}
	public function setUrl($url){
		$this->url=$url;
		if($this->setstr=="")
			$this->setstr="url='".$url."'";
		else
			$this->setstr.=",url='".$url."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="url";
			$this->values="'".$url."'";
		}else{
			$this->fields.=",url";
			$this->values.=",'".$url."'";
		}
	}
	public function getLogo(){
		return $this->logo;
	}
	public function setLogo($logo){
		$this->logo=$logo;
		if($this->setstr=="")
			$this->setstr="logo='".$logo."'";
		else
			$this->setstr.=",logo='".$logo."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="logo";
			$this->values="'".$logo."'";
		}else{
			$this->fields.=",logo";
			$this->values.=",'".$logo."'";
		}
	}
	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 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("#__link ","*",$this->subsection);
		return $this->fetchResult($result);
	}
	public function doSelectLimit() {
		global $conn;
		$result=$conn->SelectArrayLimit("#__link ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResult($result);
	}
	public function doSelectOne() {
		global $conn;
		$result=$conn->SelectRow("#__link ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResultOne($result);
	}
	public function doCount() {
		global $conn;
		return $conn->SelectCount("#__link ","*",$this->subsection);
	}
	public function doInsert() {
		global $conn;
		return $conn->Insert("#__link ",$this->fields,$this->values);
	}
	public function doDelete() {
		global $conn;
		return $conn->Delete("#__link ",$this->subsection);
	}
	public function doUpdate() {
		global $conn;
		return $conn->Update("#__link ",$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++){
			$link=new model_Link();
			$link->linkId=$result[$i]["link_id"];
			$link->categoryId=$result[$i]["category_id"];
			$link->userId=$result[$i]["user_id"];
			$link->orderid=$result[$i]["orderid"];
			$link->title=$result[$i]["title"];
			$link->url=$result[$i]["url"];
			$link->logo=$result[$i]["logo"];
			$link->summary=$result[$i]["summary"];
			$array->append($link);
		}
		return $array;
	}
	public function fetchResultOne($result){
		if(!$result){
			return $result;
		}
		$link=new model_Link();
		$link->linkId=$result["link_id"];
		$link->categoryId=$result["category_id"];
		$link->userId=$result["user_id"];
		$link->orderid=$result["orderid"];
		$link->title=$result["title"];
		$link->url=$result["url"];
		$link->logo=$result["logo"];
		$link->summary=$result["summary"];
		return $link;
	}
}
?>