<?php
/**
 *	Generated by miceCMS
 *	Date: 2010-11-18 10:50:22
 */
class model_Article {
	private $subsection="";
	private $setstr="";
	private $fields="";
	private $values="";
	private $nrows="";
	private $offset="";
	private $pages=10;
	private $pagenum=1;
	private $articleId=Null;		//	 field type: "int(11+int)"
	private $categoryId=Null;		//	 field type: "varchar(200+varchar)"
	private $userId=0;		//	 field type: "int(11+int)"
	private $title=Null;		//	 field type: "varchar(200+varchar)"
	private $createdat=0;		//	 field type: "int(11+int)"
	private $type=0;		//	 field type: "varchar(25+varchar)"
	private $img=Null;		//	 field type: "varchar(200+varchar)"
	private $upfile=Null;		//	 field type: "varchar(200+varchar)"
	private $content=Null;		//	 field type: "longtext(+longtext)"
	private $summary=Null;		//	 field type: "text(+text)"
	private $tags=Null;		//	 field type: "varchar(255+varchar)"
	private $comefrom=Null;		//	 field type: "varchar(100+varchar)"
	private $istop=0;		//	 field type: "int(11+int)"
	private $iscommend=0;		//	 field type: "int(11+int)"
	private $isremark=0;		//	 field type: "int(11+int)"
	private $isvisible=0;		//	 field type: "int(11+int)"
	private $browses=0;		//	 field type: "int(11+int)"
	private $renums=0;		//	 field type: "int(11+int)"
	private $grade=0.00;		//	 field type: "varchar(16+varchar)"
	private $ip=Null;		//	 field type: "varchar(100+varchar)"
	private $url=Null;		//	 field type: "varchar(200+varchar)"
	private $target=Null;		//	 field type: "varchar(20+varchar)"
	private $filename=Null;		//	 field type: "varchar(255+varchar)"
	private $pointnum=0;		//	 field type: "int(11+int)"
	private $ishtml=Null;		//	 field type: "varchar(255+varchar)"
	private $usergroupId=-1;		//	 field type: "int(11+int)"

	public function getArticleId(){
		return $this->articleId;
	}
	public function setArticleId($articleId){
		$this->articleId=$articleId;
		if($this->setstr=="")
			$this->setstr="article_id=".$articleId."";
		else
			$this->setstr.=",article_id=".$articleId."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="article_id";
			$this->values="".$articleId."";
		}else{
			$this->fields.=",article_id";
			$this->values.=",".$articleId."";
		}
	}
	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 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 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 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 getImg(){
		return $this->img;
	}
	public function setImg($img){
		$this->img=$img;
		if($this->setstr=="")
			$this->setstr="img='".$img."'";
		else
			$this->setstr.=",img='".$img."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="img";
			$this->values="'".$img."'";
		}else{
			$this->fields.=",img";
			$this->values.=",'".$img."'";
		}
	}
	public function getUpfile(){
		return $this->upfile;
	}
	public function setUpfile($upfile){
		$this->upfile=$upfile;
		if($this->setstr=="")
			$this->setstr="upfile='".$upfile."'";
		else
			$this->setstr.=",upfile='".$upfile."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="upfile";
			$this->values="'".$upfile."'";
		}else{
			$this->fields.=",upfile";
			$this->values.=",'".$upfile."'";
		}
	}
	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 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 getTags(){
		return $this->tags;
	}
	public function setTags($tags){
		$this->tags=$tags;
		if($this->setstr=="")
			$this->setstr="tags='".$tags."'";
		else
			$this->setstr.=",tags='".$tags."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="tags";
			$this->values="'".$tags."'";
		}else{
			$this->fields.=",tags";
			$this->values.=",'".$tags."'";
		}
	}
	public function getComefrom(){
		return $this->comefrom;
	}
	public function setComefrom($comefrom){
		$this->comefrom=$comefrom;
		if($this->setstr=="")
			$this->setstr="comefrom='".$comefrom."'";
		else
			$this->setstr.=",comefrom='".$comefrom."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="comefrom";
			$this->values="'".$comefrom."'";
		}else{
			$this->fields.=",comefrom";
			$this->values.=",'".$comefrom."'";
		}
	}
	public function getIstop(){
		return $this->istop;
	}
	public function setIstop($istop){
		$this->istop=$istop;
		if($this->setstr=="")
			$this->setstr="istop=".$istop."";
		else
			$this->setstr.=",istop=".$istop."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="istop";
			$this->values="".$istop."";
		}else{
			$this->fields.=",istop";
			$this->values.=",".$istop."";
		}
	}
	public function getIscommend(){
		return $this->iscommend;
	}
	public function setIscommend($iscommend){
		$this->iscommend=$iscommend;
		if($this->setstr=="")
			$this->setstr="iscommend=".$iscommend."";
		else
			$this->setstr.=",iscommend=".$iscommend."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="iscommend";
			$this->values="".$iscommend."";
		}else{
			$this->fields.=",iscommend";
			$this->values.=",".$iscommend."";
		}
	}
	public function getIsremark(){
		return $this->isremark;
	}
	public function setIsremark($isremark){
		$this->isremark=$isremark;
		if($this->setstr=="")
			$this->setstr="isremark=".$isremark."";
		else
			$this->setstr.=",isremark=".$isremark."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="isremark";
			$this->values="".$isremark."";
		}else{
			$this->fields.=",isremark";
			$this->values.=",".$isremark."";
		}
	}
	public function getIsvisible(){
		return $this->isvisible;
	}
	public function setIsvisible($isvisible){
		$this->isvisible=$isvisible;
		if($this->setstr=="")
			$this->setstr="isvisible=".$isvisible."";
		else
			$this->setstr.=",isvisible=".$isvisible."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="isvisible";
			$this->values="".$isvisible."";
		}else{
			$this->fields.=",isvisible";
			$this->values.=",".$isvisible."";
		}
	}
	public function getBrowses(){
		return $this->browses;
	}
	public function setBrowses($browses){
		$this->browses=$browses;
		if($this->setstr=="")
			$this->setstr="browses=".$browses."";
		else
			$this->setstr.=",browses=".$browses."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="browses";
			$this->values="".$browses."";
		}else{
			$this->fields.=",browses";
			$this->values.=",".$browses."";
		}
	}
	public function getRenums(){
		return $this->renums;
	}
	public function setRenums($renums){
		$this->renums=$renums;
		if($this->setstr=="")
			$this->setstr="renums=".$renums."";
		else
			$this->setstr.=",renums=".$renums."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="renums";
			$this->values="".$renums."";
		}else{
			$this->fields.=",renums";
			$this->values.=",".$renums."";
		}
	}
	public function getGrade(){
		return $this->grade;
	}
	public function setGrade($grade){
		$this->grade=$grade;
		if($this->setstr=="")
			$this->setstr="grade='".$grade."'";
		else
			$this->setstr.=",grade='".$grade."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="grade";
			$this->values="'".$grade."'";
		}else{
			$this->fields.=",grade";
			$this->values.=",'".$grade."'";
		}
	}
	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 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 getTarget(){
		return $this->target;
	}
	public function setTarget($target){
		$this->target=$target;
		if($this->setstr=="")
			$this->setstr="target='".$target."'";
		else
			$this->setstr.=",target='".$target."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="target";
			$this->values="'".$target."'";
		}else{
			$this->fields.=",target";
			$this->values.=",'".$target."'";
		}
	}
	public function getFilename(){
		return $this->filename;
	}
	public function setFilename($filename){
		$this->filename=$filename;
		if($this->setstr=="")
			$this->setstr="filename='".$filename."'";
		else
			$this->setstr.=",filename='".$filename."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="filename";
			$this->values="'".$filename."'";
		}else{
			$this->fields.=",filename";
			$this->values.=",'".$filename."'";
		}
	}
	public function getPointnum(){
		return $this->pointnum;
	}
	public function setPointnum($pointnum){
		$this->pointnum=$pointnum;
		if($this->setstr=="")
			$this->setstr="pointnum=".$pointnum."";
		else
			$this->setstr.=",pointnum=".$pointnum."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="pointnum";
			$this->values="".$pointnum."";
		}else{
			$this->fields.=",pointnum";
			$this->values.=",".$pointnum."";
		}
	}
	public function getIshtml(){
		return $this->ishtml;
	}
	public function setIshtml($ishtml){
		$this->ishtml=$ishtml;
		if($this->setstr=="")
			$this->setstr="ishtml='".$ishtml."'";
		else
			$this->setstr.=",ishtml='".$ishtml."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="ishtml";
			$this->values="'".$ishtml."'";
		}else{
			$this->fields.=",ishtml";
			$this->values.=",'".$ishtml."'";
		}
	}
	public function getUsergroupId(){
		return $this->usergroupId;
	}
	public function setUsergroupId($usergroupId){
		$this->usergroupId=$usergroupId;
		if($this->setstr=="")
			$this->setstr="usergroup_id=".$usergroupId."";
		else
			$this->setstr.=",usergroup_id=".$usergroupId."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="usergroup_id";
			$this->values="".$usergroupId."";
		}else{
			$this->fields.=",usergroup_id";
			$this->values.=",".$usergroupId."";
		}
	}
	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("#__article ","*",$this->subsection);
		return $this->fetchResult($result);
	}
	public function doSelectLimit() {
		global $conn;
		$result=$conn->SelectArrayLimit("#__article ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResult($result);
	}
	public function doSelectOne() {
		global $conn;
		$result=$conn->SelectRow("#__article ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResultOne($result);
	}
	public function doCount() {
		global $conn;
		return $conn->SelectCount("#__article ","*",$this->subsection);
	}
	public function doInsert() {
		global $conn;
		return $conn->Insert("#__article ",$this->fields,$this->values);
	}
	public function doDelete() {
		global $conn;
		return $conn->Delete("#__article ",$this->subsection);
	}
	public function doUpdate() {
		global $conn;
		return $conn->Update("#__article ",$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++){
			$article=new model_Article();
			$article->articleId=$result[$i]["article_id"];
			$article->categoryId=$result[$i]["category_id"];
			$article->userId=$result[$i]["user_id"];
			$article->title=$result[$i]["title"];
			$article->createdat=$result[$i]["createdat"];
			$article->type=$result[$i]["type"];
			$article->img=$result[$i]["img"];
			$article->upfile=$result[$i]["upfile"];
			$article->content=$result[$i]["content"];
			$article->summary=$result[$i]["summary"];
			$article->tags=$result[$i]["tags"];
			$article->comefrom=$result[$i]["comefrom"];
			$article->istop=$result[$i]["istop"];
			$article->iscommend=$result[$i]["iscommend"];
			$article->isremark=$result[$i]["isremark"];
			$article->isvisible=$result[$i]["isvisible"];
			$article->browses=$result[$i]["browses"];
			$article->renums=$result[$i]["renums"];
			$article->grade=$result[$i]["grade"];
			$article->ip=$result[$i]["ip"];
			$article->url=$result[$i]["url"];
			$article->target=$result[$i]["target"];
			$article->filename=$result[$i]["filename"];
			$article->pointnum=$result[$i]["pointnum"];
			$article->ishtml=$result[$i]["ishtml"];
			$article->usergroupId=$result[$i]["usergroup_id"];
			$array->append($article);
		}
		return $array;
	}
	public function fetchResultOne($result){
		if(!$result){
			return $result;
		}
		$article=new model_Article();
		$article->articleId=$result["article_id"];
		$article->categoryId=$result["category_id"];
		$article->userId=$result["user_id"];
		$article->title=$result["title"];
		$article->createdat=$result["createdat"];
		$article->type=$result["type"];
		$article->img=$result["img"];
		$article->upfile=$result["upfile"];
		$article->content=$result["content"];
		$article->summary=$result["summary"];
		$article->tags=$result["tags"];
		$article->comefrom=$result["comefrom"];
		$article->istop=$result["istop"];
		$article->iscommend=$result["iscommend"];
		$article->isremark=$result["isremark"];
		$article->isvisible=$result["isvisible"];
		$article->browses=$result["browses"];
		$article->renums=$result["renums"];
		$article->grade=$result["grade"];
		$article->ip=$result["ip"];
		$article->url=$result["url"];
		$article->target=$result["target"];
		$article->filename=$result["filename"];
		$article->pointnum=$result["pointnum"];
		$article->ishtml=$result["ishtml"];
		$article->usergroupId=$result["usergroup_id"];
		return $article;
	}
}
?>