getGoodsPartitions(); $this->assign("partitions",$par"/> getGoodsPartitions(); $this->assign("partitions",$par">
首頁 > 後端開發 > php教程 > 帮忙看下如何把下面代码调用每月的数据改成调用所有数据或某年份的数据

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

WBOY
發布: 2016-06-13 12:24:11
原創
796 人瀏覽過

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

	//往期团购列表<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 />	}
登入後複製



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


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

这个函数长什么样子

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板