|  | @@ -0,0 +1,156 @@
 | 
	
		
			
				|  |  | +<?php
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +Doo::loadCore ( 'db/DooModel' );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +class Article extends DooModel {
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	public $aid;
 | 
	
		
			
				|  |  | +	public $title;
 | 
	
		
			
				|  |  | +	public $content;
 | 
	
		
			
				|  |  | +	public $synopsis;
 | 
	
		
			
				|  |  | +	public $thum;
 | 
	
		
			
				|  |  | +	public $a_type;
 | 
	
		
			
				|  |  | +	public $trainingType;
 | 
	
		
			
				|  |  | +	public $area;
 | 
	
		
			
				|  |  | +	public $enroll;
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	public $enroll_title;
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	public $enroll_obj;
 | 
	
		
			
				|  |  | +	public $enroll_content;
 | 
	
		
			
				|  |  | +	public $enroll_fun;
 | 
	
		
			
				|  |  | +	public $enroll_adrr;
 | 
	
		
			
				|  |  | +	public $enroll_pay;
 | 
	
		
			
				|  |  | +	public $enroll_name;
 | 
	
		
			
				|  |  | +	public $enroll_downdoc;
 | 
	
		
			
				|  |  | +	public $enroll_mark;
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	public $attachment;
 | 
	
		
			
				|  |  | +	public $cid;
 | 
	
		
			
				|  |  | +	public $enroll_time;
 | 
	
		
			
				|  |  | +	public $time;
 | 
	
		
			
				|  |  | +	public $update_time;
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	public $_table = 'sc_article';
 | 
	
		
			
				|  |  | +	public $_primarykey = 'aid';
 | 
	
		
			
				|  |  | +	public $_fields = array ('aid', 'title', 'content','synopsis','thum' ,'a_type','trainingType','area','enroll_title', 'enroll','enroll_obj','enroll_content',
 | 
	
		
			
				|  |  | +	 'enroll_fun','enroll_adrr','enroll_pay','enroll_name','enroll_downdoc','enroll_mark','attachment', 'cid','enroll_time', 'time','update_time' );
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	function getArticleById($aid = 0) {
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		return $this->find ( array ('desc' => 'time', 'where' => 'aid=' . $aid, 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	function getArticleByTrain($trainingType=2){
 | 
	
		
			
				|  |  | +		return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2 and trainingType='.$trainingType, 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//	function getArticleByTrain2($trainingType= '',$area = ''){
 | 
	
		
			
				|  |  | +//		$sql = '';
 | 
	
		
			
				|  |  | +//		if($trainingType != ''){
 | 
	
		
			
				|  |  | +//			$sql .= '  and trainingType='.$trainingType;
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//		if($area != ''){
 | 
	
		
			
				|  |  | +//			$sql .= ' and area="'.$area.'"';
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//		$sql .= ' and time+63072000 >= unix_timestamp(now())';
 | 
	
		
			
				|  |  | +//		return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2'.$sql, 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +//	}
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//	function getArticleByTrain3(){
 | 
	
		
			
				|  |  | +//		$sql = '';
 | 
	
		
			
				|  |  | +//		$sql .= ' and time+63072000 >= unix_timestamp(now())';
 | 
	
		
			
				|  |  | +//		return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2'.$sql, 'limit' => 50, 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +//	}
 | 
	
		
			
				|  |  | +    function getArticleByTrain2($trainingType= '',$area = '', $select = false){
 | 
	
		
			
				|  |  | +        $sql = '';
 | 
	
		
			
				|  |  | +        if($trainingType != '' && is_numeric($trainingType)){
 | 
	
		
			
				|  |  | +            $sql .= '  and trainingType='.$trainingType;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if($area != ''){
 | 
	
		
			
				|  |  | +            $sql .= ' and area="'.$area.'"';
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $sql .= ' and time+63072000 >= unix_timestamp(now())';
 | 
	
		
			
				|  |  | +        if ($select) {
 | 
	
		
			
				|  |  | +            return $this->find ( array ('select'=> 'aid,area,trainingType,time,enroll_time,enroll_title', 'desc' => 'time', 'where' => 'a_type=2'.$sql, 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2'.$sql, 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    function getArticleByTrain3($select = false){
 | 
	
		
			
				|  |  | +        $sql = '';
 | 
	
		
			
				|  |  | +        $sql .= ' and time+63072000 >= unix_timestamp(now())';
 | 
	
		
			
				|  |  | +        if ($select) {
 | 
	
		
			
				|  |  | +            return $this->find ( array ('select'=> 'aid,area,trainingType,time,enroll_time,enroll_title', 'desc' => 'time', 'where' => 'a_type=2'.$sql, 'limit' => 50, 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2'.$sql, 'limit' => 50, 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	function getArticleNumByTrain2($trainingType= '',$area = ''){
 | 
	
		
			
				|  |  | +		$sql = '';
 | 
	
		
			
				|  |  | +		if($trainingType != '' && is_numeric($trainingType)){
 | 
	
		
			
				|  |  | +			$sql .= '  and trainingType='.$trainingType;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		if($area != ''){
 | 
	
		
			
				|  |  | +			$sql .= ' and area="'.$area.'"';
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		$sql .= ' and time+63072000 >= unix_timestamp(now())';
 | 
	
		
			
				|  |  | +		return $this->count ( array ('where' => 'a_type=2'.$sql, 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	function getArticleByTrainAid($aid){
 | 
	
		
			
				|  |  | +		return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2 and aid='.$aid, 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	function getArticleByCid($cid = 0,$limit) {
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		return $this->find ( array ('desc' => 'time', 'limit'=>$limit , 'where' => 'cid=' . $cid, 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +function getArticleByCid3($cid = 0,$limit) {
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		return $this->find ( array ('desc' => 'update_time', 'limit'=>$limit , 'where' => 'cid=' . $cid, 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +function getArticleByCid2($cid = 0,$limit) {
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		return $this->find ( array ('desc' => 'update_time', 'limit'=>$limit , 'where' => '(cid=' . $cid .' or cid=3 or cid=7) and title !=""', 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	function getArticleList($data = array(), $condition = "", $limit = ""){
 | 
	
		
			
				|  |  | +		foreach ( $data as $key => $value ) {
 | 
	
		
			
				|  |  | +			if (is_numeric ( $value ))
 | 
	
		
			
				|  |  | +				$condition .= " and " . $key . " = " . $value;
 | 
	
		
			
				|  |  | +			else
 | 
	
		
			
				|  |  | +				$condition .= " and " . $key . " like '%" . $value . "%' ";
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$condition = ' where 1 ' . $condition . $limit;
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$sql = "select * from " . $this->_table . $condition;
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$query = Doo::db ()->query ( $sql );
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$result = $query->fetchAll ();
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		return $result;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	function deleteArticleByIdList($id){
 | 
	
		
			
				|  |  | +		$id = implode ( ",", $id );
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$sql = "delete from " . $this->_table . " where aid in ( " . $id . " )";
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		Doo::db ()->query ( $sql );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	function getArticleListbyLimit($sql, $limit){
 | 
	
		
			
				|  |  | +		return $this->find ( array ('where' => $sql, 'desc' => 'time', 'limit'=>$limit, 'asArray' => TRUE ) );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +?>
 |