<?php
/**
 *	Generated by miceCMS
 *	Date: 2010-11-18 10:50:22
 */
class model_User {
	private $subsection="";
	private $setstr="";
	private $fields="";
	private $values="";
	private $nrows="";
	private $offset="";
	private $pages=10;
	private $pagenum=1;
	private $userId=Null;		//	 field type: "int(11+int)"
	private $loginname=Null;		//	 field type: "varchar(30+varchar)"
	private $salt=Null;		//	 field type: "varchar(32+varchar)"
	private $password=Null;		//	 field type: "varchar(40+varchar)"
	private $postnums=0;		//	 field type: "int(11+int)"
	private $realname=Null;		//	 field type: "varchar(30+varchar)"
	private $explam=Null;		//	 field type: "text(+text)"
	private $url=Null;		//	 field type: "varchar(200+varchar)"
	private $email=Null;		//	 field type: "varchar(200+varchar)"
	private $regdate=0;		//	 field type: "int(11+int)"
	private $stopdate=0;		//	 field type: "int(11+int)"
	private $usergroupId=0;		//	 field type: "int(11+int)"
	private $pointnum=0;		//	 field type: "int(11+int)"
	private $status=0;		//	 field type: "int(11+int)"
	private $nicename=Null;		//	 field type: "varchar(30+varchar)"
	private $address=Null;		//	 field type: "varchar(200+varchar)"
	private $headimg=Null;		//	 field type: "varchar(200+varchar)"
	private $brothday=Null;		//	 field type: "varchar(10+varchar)"
	private $sex=0;		//	 field type: "int(11+int)"
	private $im=Null;		//	 field type: "varchar(200+varchar)"
	private $telno=Null;		//	 field type: "varchar(100+varchar)"
	private $lastlogindate=0;		//	 field type: "int(11+int)"
	private $lastloginip=Null;		//	 field type: "varchar(100+varchar)"
	private $forgetpwd=Null;		//	 field type: "varchar(200+varchar)"
	private $memo=Null;		//	 field type: "text(+text)"

	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 getLoginname(){
		return $this->loginname;
	}
	public function setLoginname($loginname){
		$this->loginname=$loginname;
		if($this->setstr=="")
			$this->setstr="loginname='".$loginname."'";
		else
			$this->setstr.=",loginname='".$loginname."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="loginname";
			$this->values="'".$loginname."'";
		}else{
			$this->fields.=",loginname";
			$this->values.=",'".$loginname."'";
		}
	}
	public function getSalt(){
		return $this->salt;
	}
	public function setSalt($salt){
		$this->salt=$salt;
		if($this->setstr=="")
			$this->setstr="salt='".$salt."'";
		else
			$this->setstr.=",salt='".$salt."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="salt";
			$this->values="'".$salt."'";
		}else{
			$this->fields.=",salt";
			$this->values.=",'".$salt."'";
		}
	}
	public function getPassword(){
		return $this->password;
	}
	public function setPassword($password){
		$this->password=$password;
		if($this->setstr=="")
			$this->setstr="password='".$password."'";
		else
			$this->setstr.=",password='".$password."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="password";
			$this->values="'".$password."'";
		}else{
			$this->fields.=",password";
			$this->values.=",'".$password."'";
		}
	}
	public function getPostnums(){
		return $this->postnums;
	}
	public function setPostnums($postnums){
		$this->postnums=$postnums;
		if($this->setstr=="")
			$this->setstr="postnums=".$postnums."";
		else
			$this->setstr.=",postnums=".$postnums."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="postnums";
			$this->values="".$postnums."";
		}else{
			$this->fields.=",postnums";
			$this->values.=",".$postnums."";
		}
	}
	public function getRealname(){
		return $this->realname;
	}
	public function setRealname($realname){
		$this->realname=$realname;
		if($this->setstr=="")
			$this->setstr="realname='".$realname."'";
		else
			$this->setstr.=",realname='".$realname."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="realname";
			$this->values="'".$realname."'";
		}else{
			$this->fields.=",realname";
			$this->values.=",'".$realname."'";
		}
	}
	public function getExplam(){
		return $this->explam;
	}
	public function setExplam($explam){
		$this->explam=$explam;
		if($this->setstr=="")
			$this->setstr="explam='".$explam."'";
		else
			$this->setstr.=",explam='".$explam."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="explam";
			$this->values="'".$explam."'";
		}else{
			$this->fields.=",explam";
			$this->values.=",'".$explam."'";
		}
	}
	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 getEmail(){
		return $this->email;
	}
	public function setEmail($email){
		$this->email=$email;
		if($this->setstr=="")
			$this->setstr="email='".$email."'";
		else
			$this->setstr.=",email='".$email."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="email";
			$this->values="'".$email."'";
		}else{
			$this->fields.=",email";
			$this->values.=",'".$email."'";
		}
	}
	public function getRegdate(){
		return $this->regdate;
	}
	public function setRegdate($regdate){
		$this->regdate=$regdate;
		if($this->setstr=="")
			$this->setstr="regdate=".$regdate."";
		else
			$this->setstr.=",regdate=".$regdate."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="regdate";
			$this->values="".$regdate."";
		}else{
			$this->fields.=",regdate";
			$this->values.=",".$regdate."";
		}
	}
	public function getStopdate(){
		return $this->stopdate;
	}
	public function setStopdate($stopdate){
		$this->stopdate=$stopdate;
		if($this->setstr=="")
			$this->setstr="stopdate=".$stopdate."";
		else
			$this->setstr.=",stopdate=".$stopdate."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="stopdate";
			$this->values="".$stopdate."";
		}else{
			$this->fields.=",stopdate";
			$this->values.=",".$stopdate."";
		}
	}
	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 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 getStatus(){
		return $this->status;
	}
	public function setStatus($status){
		$this->status=$status;
		if($this->setstr=="")
			$this->setstr="status=".$status."";
		else
			$this->setstr.=",status=".$status."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="status";
			$this->values="".$status."";
		}else{
			$this->fields.=",status";
			$this->values.=",".$status."";
		}
	}
	public function getNicename(){
		return $this->nicename;
	}
	public function setNicename($nicename){
		$this->nicename=$nicename;
		if($this->setstr=="")
			$this->setstr="nicename='".$nicename."'";
		else
			$this->setstr.=",nicename='".$nicename."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="nicename";
			$this->values="'".$nicename."'";
		}else{
			$this->fields.=",nicename";
			$this->values.=",'".$nicename."'";
		}
	}
	public function getAddress(){
		return $this->address;
	}
	public function setAddress($address){
		$this->address=$address;
		if($this->setstr=="")
			$this->setstr="address='".$address."'";
		else
			$this->setstr.=",address='".$address."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="address";
			$this->values="'".$address."'";
		}else{
			$this->fields.=",address";
			$this->values.=",'".$address."'";
		}
	}
	public function getHeadimg(){
		return $this->headimg;
	}
	public function setHeadimg($headimg){
		$this->headimg=$headimg;
		if($this->setstr=="")
			$this->setstr="headimg='".$headimg."'";
		else
			$this->setstr.=",headimg='".$headimg."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="headimg";
			$this->values="'".$headimg."'";
		}else{
			$this->fields.=",headimg";
			$this->values.=",'".$headimg."'";
		}
	}
	public function getBrothday(){
		return $this->brothday;
	}
	public function setBrothday($brothday){
		$this->brothday=$brothday;
		if($this->setstr=="")
			$this->setstr="brothday='".$brothday."'";
		else
			$this->setstr.=",brothday='".$brothday."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="brothday";
			$this->values="'".$brothday."'";
		}else{
			$this->fields.=",brothday";
			$this->values.=",'".$brothday."'";
		}
	}
	public function getSex(){
		return $this->sex;
	}
	public function setSex($sex){
		$this->sex=$sex;
		if($this->setstr=="")
			$this->setstr="sex=".$sex."";
		else
			$this->setstr.=",sex=".$sex."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="sex";
			$this->values="".$sex."";
		}else{
			$this->fields.=",sex";
			$this->values.=",".$sex."";
		}
	}
	public function getIm(){
		return $this->im;
	}
	public function setIm($im){
		$this->im=$im;
		if($this->setstr=="")
			$this->setstr="im='".$im."'";
		else
			$this->setstr.=",im='".$im."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="im";
			$this->values="'".$im."'";
		}else{
			$this->fields.=",im";
			$this->values.=",'".$im."'";
		}
	}
	public function getTelno(){
		return $this->telno;
	}
	public function setTelno($telno){
		$this->telno=$telno;
		if($this->setstr=="")
			$this->setstr="telno='".$telno."'";
		else
			$this->setstr.=",telno='".$telno."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="telno";
			$this->values="'".$telno."'";
		}else{
			$this->fields.=",telno";
			$this->values.=",'".$telno."'";
		}
	}
	public function getLastlogindate(){
		return $this->lastlogindate;
	}
	public function setLastlogindate($lastlogindate){
		$this->lastlogindate=$lastlogindate;
		if($this->setstr=="")
			$this->setstr="lastlogindate=".$lastlogindate."";
		else
			$this->setstr.=",lastlogindate=".$lastlogindate."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="lastlogindate";
			$this->values="".$lastlogindate."";
		}else{
			$this->fields.=",lastlogindate";
			$this->values.=",".$lastlogindate."";
		}
	}
	public function getLastloginip(){
		return $this->lastloginip;
	}
	public function setLastloginip($lastloginip){
		$this->lastloginip=$lastloginip;
		if($this->setstr=="")
			$this->setstr="lastloginip='".$lastloginip."'";
		else
			$this->setstr.=",lastloginip='".$lastloginip."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="lastloginip";
			$this->values="'".$lastloginip."'";
		}else{
			$this->fields.=",lastloginip";
			$this->values.=",'".$lastloginip."'";
		}
	}
	public function getForgetpwd(){
		return $this->forgetpwd;
	}
	public function setForgetpwd($forgetpwd){
		$this->forgetpwd=$forgetpwd;
		if($this->setstr=="")
			$this->setstr="forgetpwd='".$forgetpwd."'";
		else
			$this->setstr.=",forgetpwd='".$forgetpwd."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="forgetpwd";
			$this->values="'".$forgetpwd."'";
		}else{
			$this->fields.=",forgetpwd";
			$this->values.=",'".$forgetpwd."'";
		}
	}
	public function getMemo(){
		return $this->memo;
	}
	public function setMemo($memo){
		$this->memo=$memo;
		if($this->setstr=="")
			$this->setstr="memo='".$memo."'";
		else
			$this->setstr.=",memo='".$memo."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="memo";
			$this->values="'".$memo."'";
		}else{
			$this->fields.=",memo";
			$this->values.=",'".$memo."'";
		}
	}
	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("#__user ","*",$this->subsection);
		return $this->fetchResult($result);
	}
	public function doSelectLimit() {
		global $conn;
		$result=$conn->SelectArrayLimit("#__user ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResult($result);
	}
	public function doSelectOne() {
		global $conn;
		$result=$conn->SelectRow("#__user ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResultOne($result);
	}
	public function doCount() {
		global $conn;
		return $conn->SelectCount("#__user ","*",$this->subsection);
	}
	public function doInsert() {
		global $conn;
		return $conn->Insert("#__user ",$this->fields,$this->values);
	}
	public function doDelete() {
		global $conn;
		return $conn->Delete("#__user ",$this->subsection);
	}
	public function doUpdate() {
		global $conn;
		return $conn->Update("#__user ",$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++){
			$user=new model_User();
			$user->userId=$result[$i]["user_id"];
			$user->loginname=$result[$i]["loginname"];
			$user->salt=$result[$i]["salt"];
			$user->password=$result[$i]["password"];
			$user->postnums=$result[$i]["postnums"];
			$user->realname=$result[$i]["realname"];
			$user->explam=$result[$i]["explam"];
			$user->url=$result[$i]["url"];
			$user->email=$result[$i]["email"];
			$user->regdate=$result[$i]["regdate"];
			$user->stopdate=$result[$i]["stopdate"];
			$user->usergroupId=$result[$i]["usergroup_id"];
			$user->pointnum=$result[$i]["pointnum"];
			$user->status=$result[$i]["status"];
			$user->nicename=$result[$i]["nicename"];
			$user->address=$result[$i]["address"];
			$user->headimg=$result[$i]["headimg"];
			$user->brothday=$result[$i]["brothday"];
			$user->sex=$result[$i]["sex"];
			$user->im=$result[$i]["im"];
			$user->telno=$result[$i]["telno"];
			$user->lastlogindate=$result[$i]["lastlogindate"];
			$user->lastloginip=$result[$i]["lastloginip"];
			$user->forgetpwd=$result[$i]["forgetpwd"];
			$user->memo=$result[$i]["memo"];
			$array->append($user);
		}
		return $array;
	}
	public function fetchResultOne($result){
		if(!$result){
			return $result;
		}
		$user=new model_User();
		$user->userId=$result["user_id"];
		$user->loginname=$result["loginname"];
		$user->salt=$result["salt"];
		$user->password=$result["password"];
		$user->postnums=$result["postnums"];
		$user->realname=$result["realname"];
		$user->explam=$result["explam"];
		$user->url=$result["url"];
		$user->email=$result["email"];
		$user->regdate=$result["regdate"];
		$user->stopdate=$result["stopdate"];
		$user->usergroupId=$result["usergroup_id"];
		$user->pointnum=$result["pointnum"];
		$user->status=$result["status"];
		$user->nicename=$result["nicename"];
		$user->address=$result["address"];
		$user->headimg=$result["headimg"];
		$user->brothday=$result["brothday"];
		$user->sex=$result["sex"];
		$user->im=$result["im"];
		$user->telno=$result["telno"];
		$user->lastlogindate=$result["lastlogindate"];
		$user->lastloginip=$result["lastloginip"];
		$user->forgetpwd=$result["forgetpwd"];
		$user->memo=$result["memo"];
		return $user;
	}
}
?>