caipin 5 年之前
父節點
當前提交
c38880b146
共有 1 個文件被更改,包括 32 次插入3 次删除
  1. 32 3
      Article.php

+ 32 - 3
Article.php

@@ -65,7 +65,35 @@ class Article extends DooModel {
 //		return $this->find ( array ('desc' => 'time', 'where' => 'a_type=2'.$sql, 'limit' => 50, 'asArray' => TRUE ) );
 //	}
     function getArticleByTrain2($trainingType= '',$area = '', $select = false){
-        $sql = '';
+    	
+    	$condition='a_type=2 ';
+    	$parameter=array();
+    	if($trainingType != '' && is_numeric($trainingType)){
+    		$condition.= '  and trainingType= ?';
+    		array_push($parameter, $trainingType);
+    	}
+    	if($area != ''){
+    		$condition.= ' and area=?';
+    		array_push($parameter, $area);
+    	}
+    	$condition.=' and time+63072000 >= unix_timestamp(now())';
+    	
+    	$qualification=array(
+    			'where' => $condition,
+    			'param' => $parameter,
+    			'desc'=>'time',
+    			'asArray' => TRUE);
+    	
+    	if ($select) {
+    		$qualification+=array('select'=> 'aid,area,trainingType,time,enroll_time,enroll_title');
+    	} 
+    	
+    	$result=$this->find($qualification);
+    	return $result;
+    	
+    	
+    	
+       /*  $sql = '';
         if($trainingType != '' && is_numeric($trainingType)){
             $sql .= '  and trainingType='.$trainingType;
         }
@@ -74,10 +102,11 @@ class Article extends DooModel {
         }
         $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 ) );
+            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){