Jelajahi Sumber

提交修改请求

lvhao 1 hari lalu
induk
melakukan
8d4c5d153c
1 mengubah file dengan 39 tambahan dan 17 penghapusan
  1. 39 17
      core/CoreApp/libraries/Common.php

+ 39 - 17
core/CoreApp/libraries/Common.php

@@ -7,27 +7,49 @@ $this->ci = &get_instance();
     /*分类*/
     function _typeclass($classid,$en=3,$num=900,$order=NULL)
     {
-	$this->ci->load->_model('Model_typeclass','typeclass');
-    $where = "classid = '$classid'";
-	if($en == '2')
-	{
-		$where .= " and spare != '0' and spare != '' and spare != 'null'";
-	}
-	if($en == '1')
-	{
-		$where .= " and ae != ''";
-	}
-    $result = $this->ci->typeclass->find_all($where,'*',$order,0,$num);
-    return $result;
+		// $this->ci->load->_model('Model_typeclass','typeclass');
+		// $where = "classid = '$classid'";
+		// if($en == '2')
+		// {
+		// 	$where .= " and spare != '0' and spare != '' and spare != 'null'";
+		// }
+		// if($en == '1')
+		// {
+		// 	$where .= " and ae != ''";
+		// }
+		// $result = $this->ci->typeclass->find_all($where,'*',$order,0,$num);
+		// return $result;
+		static $cache = array();
+		$key = $classid.'_'.$en.'_'.$num.'_'.$order;
+		if(isset($cache[$key])) return $cache[$key];
+
+		$this->ci->load->_model('Model_typeclass','typeclass');
+		$where = "classid = '$classid'";
+		if($en == '2'){ $where .= " and spare != '0' and spare != '' and spare != 'null'"; }
+		if($en == '1'){ $where .= " and ae != ''"; }
+		$result = $this->ci->typeclass->find_all($where,'*',$order,0,$num);
+		$cache[$key] = $result;
+		return $result;
 	}
 	/*分类2 这个是按照要求部分花型不显示出来*/
 	function _typeclassyc($classid,$num=900,$order=NULL)
     {
-	$this->ci->load->_model('Model_typeclass','typeclass');
-    $where = "classid = '$classid'";
-	$where .= " and id != 105 and id != 107 and id != 112 and id != 114 and id != 115 and id != 116 and id != 117 and id != 118 and id != 119 and id != 120 and id != 121 and id != 122 and id != 123 and id != 124 and id != 125 and id != 292 and id != 63 and id != 289 and id != 290 and id != 181 and id != 273 and id != 148 and id != 38 and id != 291 and id != 55 and id != 271 and id != 285 and id != 186 and id != 187 and id != 188 and id != 189 and id != 53 and id != 67";
-    $result = $this->ci->typeclass->find_all($where,'*',$order,0,$num);
-    return $result;
+		// $this->ci->load->_model('Model_typeclass','typeclass');
+		// $where = "classid = '$classid'";
+		// $where .= " and id != 105 and id != 107 and id != 112 and id != 114 and id != 115 and id != 116 and id != 117 and id != 118 and id != 119 and id != 120 and id != 121 and id != 122 and id != 123 and id != 124 and id != 125 and id != 292 and id != 63 and id != 289 and id != 290 and id != 181 and id != 273 and id != 148 and id != 38 and id != 291 and id != 55 and id != 271 and id != 285 and id != 186 and id != 187 and id != 188 and id != 189 and id != 53 and id != 67";
+		// $result = $this->ci->typeclass->find_all($where,'*',$order,0,$num);
+		// return $result;
+
+		static $cache = array();
+		$key = $classid.'_'.$num.'_'.$order;
+		if(isset($cache[$key])) return $cache[$key];
+
+		$this->ci->load->_model('Model_typeclass','typeclass');
+		$where = "classid = '$classid'";
+		$where .= " and id != 105 and id != 107 and id != 112 and id != 114 and id != 115 and id != 116 and id != 117 and id != 118 and id != 119 and id != 120 and id != 121 and id != 122 and id != 123 and id != 124 and id != 125 and id != 292 and id != 63 and id != 289 and id != 290 and id != 181 and id != 273 and id != 148 and id != 38 and id != 291 and id != 55 and id != 271 and id != 285 and id != 186 and id != 187 and id != 188 and id != 189 and id != 53 and id != 67";
+		$result = $this->ci->typeclass->find_all($where,'*',$order,0,$num);
+		$cache[$key] = $result;
+		return $result;
 	}
 	/*店铺*/
     function _shop($type,$num=900,$order=NULL)