getGoodsPartitions(); $this->assign("partitions",$par"/> getGoodsPartitions(); $this->assign("partitions",$par">
Rumah > pembangunan bahagian belakang > tutorial php > 帮忙看下如何把下面代码调用每月的数据改成调用所有数据或某年份的数据

帮忙看下如何把下面代码调用每月的数据改成调用所有数据或某年份的数据

WBOY
Lepaskan: 2016-06-13 12:24:11
asal
777 orang telah melayarinya

帮忙看下怎么把下面代码调用每月的数据改成调用所有数据或某年份的数据

	//往期团购列表<br />	public function expired()<br />	{<br />		$partitions = D("Goods")->getGoodsPartitions();<br />		$this->assign("partitions",$partitions);<br /><br />		$site_name = trim($_REQUEST['site_name']);<br />		$cate_id = intval($_REQUEST['cate_id']);<br />		$name = trim($_REQUEST['name']);<br />		$status = trim($_REQUEST['status']);<br />		$city = trim($_REQUEST['city']);<br />		$end_time = intval($_REQUEST['end_time']);<br />		if(isset($partitions[$end_time]))<br />			$partition = $partitions[$end_time];<br />		else<br />		{<br />			$partition = current($partitions);<br />			$end_time = $partition['min_date'];<br />		}<br />		$this->assign("end_time",$end_time);<br /><br />		$parameter = array();<br />		$parameter['end_time'] = $end_time;<br /><br />		$is_empty = false;<br />		$where = '';<br /><br />		if(!empty($site_name))<br />		{<br />			$this->assign("site_name",$site_name);<br />			$parameter['site_name'] = $site_name;<br />			$ids = array();<br />			$site_ids = D('Site')->where("name like '%$site_name%'")->field('id')->findAll();<br />			foreach($site_ids as $site)<br />			{<br />				$ids[] = $site['id'];<br />			}<br /><br />			if(count($ids) > 0)<br />				$where .= ' and gk.site_id in ('.implode(',', $ids).')';<br />			else<br />				$is_empty = true;<br />		}<br /><br />		if(!empty($cate_id))<br />		{<br />			$this->assign("cate_id",$cate_id);<br />			$where.=" and gk.cate_id = $cate_id";<br />			$parameter['cate_id'] = $cate_id;<br />		}<br /><br />		if(!empty($city))<br />		{<br />			$this->assign("city",$city);<br />			$where.=" and gk.city = '$city'";<br />			$parameter['city'] = $city;<br />		}<br /><br />		if(!empty($name))<br />		{<br />			$name_query = clearSymbol($name);<br />			if(!empty($name_query))<br />			{<br />				$name_query = segmentToUnicode($name_query,'+');<br />				$match_sql = ' inner join '.C("DB_PREFIX").'goods_match as gm ON gm.id = gk.id ';<br />				$where.=" AND MATCH (gm.content) AGAINST ('$name_query' IN BOOLEAN MODE)";<br />				$this->assign("name",$name);<br />				$parameter['name'] = $name;<br />			}<br />		}<br /><br />		if($status != "" && $status >= 0)<br />		{<br />			$where.=" and g.status = $status";<br />			$this->assign("status",$status);<br />			$parameter['status'] = $status;<br />		}<br />		else<br />		{<br />			$this->assign("status",-1);<br />		}<br /><br />		if(!$is_empty)<br />		{<br />			$model = M();<br />			$count_str = 'SELECT count(g.id) as gcount<br />					FROM '.C("DB_PREFIX").'goods_key as gk<br />					inner join '.C("DB_PREFIX").'goods as g on g.id = gk.id '.$match_sql.<br />					"where $partition[where] $where ";<br /><br />			$count = $model->query($count_str);<br />			$count = $count[0]['gcount'];<br /><br />			$sql_str = 'SELECT g.id,g.name,g.shop_price,g.city,g.end_time,g.status,g.is_best,g.sort,g.cate_id,g.bought,g.site_name<br />					FROM '.C("DB_PREFIX").'goods_key as gk<br />					inner join '.C("DB_PREFIX").'goods as g on g.id = gk.id  '.$match_sql.<br />					"where $partition[where] $where ";<br /><br />			$voList = $this->_sqlList($model, $sql_str, $count,$parameter, 'id', false);<br />		}<br />		else<br />			$voList = array();<br /><br />		L("FORBID","未审核");<br />		L("NORMAL","已审核");<br /><br />		$group_city_list = D("GroupCity")->where("status=1")->order("sort asc,id asc")->findAll();<br />		$this->assign("group_city_list",$group_city_list);<br /><br />		$goodsCates = D('GoodsCate')-> where("status=1")-> findAll();<br />		$goodsCates = D('GoodsCate')-> toFormatTree($goodsCates,array('name'));<br />		$this->assign("goodsCates",$goodsCates);<br /><br />		$this->display();<br />	}
Salin selepas log masuk



前台的调用代码是这样的: 
他的下拉菜单选择都是每个月的所有过期数据,我要的效果是下拉菜单加一个全部过期数据或每年份的过期数据
------解决思路----------------------
看一下  D("Goods")->getGoodsPartitions(); 这个方法,改一改


等楼下
------解决思路----------------------
$partitions = D("Goods")->getGoodsPartitions();

这个函数长什么样子

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan