首頁 後端開發 php教程 以上代码是调用24小时内的数据,请教如何改成调用一个月或一年的数据

以上代码是调用24小时内的数据,请教如何改成调用一个月或一年的数据

Jun 13, 2016 pm 01:08 PM
page sort time where

以下代码是调用24小时内的数据,请问怎么改成调用一个月或一年的数据

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->    private function getList($where='',$no_query = false)
    {
        global $_FANWE;

        if(!$no_query)
        {
            if(defined('IS_CACHE_TPL'))
                $fields = '';
            else
                $fields = ',g.post_count';

            $page_args = array(
                'city_py' => CURRENT_CITY_PY,
                'site' => intval($_FANWE['request']['site']),
                'cat' => intval($_FANWE['request']['cat']),
                'sort' => trim($_FANWE['request']['sort']),
                'date' => trim($_FANWE['request']['date']),
                'keyword' => trim($_FANWE['request']['keyword']),
                'prices' => trim($_FANWE['request']['prices']),
            );

            $site_id = 0;
            if($page_args['site'] > 0)
            {
                $site_id = $page_args['site'];
                $site_where = ' AND gk.site_id = '.$page_args['site'];
            }
            else
                unset($page_args['site']);

            $dates = S('Goods')->getExpiredGoodsDate();

            $min_time = getTodayTime();
            $max_time = TIME_UTC;
            $date = toDate($min_time,'Y-m-d');

            if(!empty($page_args['date']))
            {
                $time = str2Time($page_args['date']);
                if($time = $dates['min_time'])
                {
                    $date = toDate($time,'Y-m-d');
                    $min_time = str2Time(toDate($time,'Y-m-d'));
                    $max_time = $min_time + 863990000;
                    if($max_time > TIME_UTC)
                        $max_time = TIME_UTC;
                }
            }
            else
            {
                $page_args['date'] = $date;
            }

            $dates['min_time'] = toDate($dates['min_time'],'r');
            $dates['max_time'] = toDate($dates['max_time'],'r');

              $where.=" AND gk.end_time >= '$min_time' AND gk.end_time  0)
                $insert_sort = 'gk.ec_sort ASC';

            if(in_array($page_args['cat'],$_FANWE['cache']['goods']['root_cates']))
                $insert_sort = 'gk.dc_sort ASC';


            $city_name = $_FANWE['current_city']['name'];

            if(CURRENT_CITY_PY == CHINA_CITY_PY)
            {
                //全国不包含所有城市商品时
                if($_FANWE['setting']['all_city'] == 0)
                    $where.=  " AND gk.city = '$city_name'";
                else
                {
                    $insert_sort = 'gk.r_sort ASC';

                    if($page_args['cat'] > 0)
                        $insert_sort = 'gk.e_sort ASC';

                    if(in_array($page_args['cat'],$_FANWE['cache']['goods']['root_cates']))
                        $insert_sort = 'gk.d_sort ASC';
                }
            }
            elseif(CURRENT_CITY_PY != '')
            {
                //城市显示全国商品时
                if($_FANWE['setting']['index_all'] == 1)
                {
                    $fields .= ",(gk.city = '$city_name') as is_now_city";
                    $insert_sort = 'is_now_city DESC,'.$insert_sort;
                    $quanguo_name = $_FANWE['cache']['city']['all'][CHINA_CITY_PY]['name'];
                    $where.=  " AND gk.city IN ('$city_name','$quanguo_name')";
                }
                else
                {
                    $where.=  " AND gk.city = '$city_name'";
                }
            }

            //价格条件
            $prices = '';
            if(!empty($page_args['prices']))
            {
                $prices = &$page_args['prices'];
                $price_arr = explode(',',$prices);
                $price_min = intval($price_arr[0]);
                $price_max = intval($price_arr[1]);

                if($price_min > 0)
                    $where.=" AND (g.shop_price >= $price_min)";

                if($price_max > 0)
                    $where.=" AND (g.shop_price getExpiredGoodsCats($site_where.$where);

            $cate_id = 0;
            if($page_args['cat'] > 0)
            {
                $cate_id = &$page_args['cat'];
                $cateobj = $_FANWE['cache']['goods']['cats'][$cate_id];
                $cate_ids = array();
                if(isset($cateobj['childs']))
                    $cate_ids = $cateobj['childs'];

                $cate_ids[] = $cate_id;

                if(count($cate_ids) > 1)
                    $where.=' AND gk.cate_id IN ('.implode(',', $cate_ids).')';
                else
                    $where.=" AND gk.cate_id = '$cate_id'";
            }
            else
                unset($page_args['cat']);

            $goods_sites = S('Goods')->getExpiredGoodsSites($where);

            $where = $site_where.$where;

            $order = '';
            $sort = &$page_args['sort'];
            $sort_array = array('spa'=>'g.shop_price ASC','spd'=>'g.shop_price DESC','eta'=>'g.end_time ASC','etd'=>'g.end_time DESC','cca'=>'g.click_count ASC','ccd'=>'g.click_count DESC','sa'=>'g.score ASC','sd'=>'g.score DESC','ba'=>'g.bought ASC','bd'=>'g.bought DESC','da'=>'discount ASC','dd'=>'discount DESC');

            if(array_key_exists($sort,$sort_array))
                $order = $sort_array[$sort];
            else
            {
                unset($page_args['sort']);
                $sort = '';
            }

            if(empty($order))
                $order .= 'g.is_best DESC,'.$insert_sort.',g.sort ASC,g.id ASC';
            else
                $order .= ','.$insert_sort.',g.sort ASC,g.id DESC';

            $goods_count = S('Goods')->getExpiredGoodsCount($where);

            $pager = buildPage('goods/'.ACTION_NAME,$page_args,$goods_count,$_FANWE['page'],15);
            $goods_result = S('Goods')->getExpiredGoodsList($where,$order,$fields,$pager['limit']);
            $goods_result['ids'] = implode(',',$goods_result['ids']);
        }

        include template('page/goods_index');
    }
 <div class="clear">
                 
              
              
        
            </div>
登入後複製
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

<🎜>:泡泡膠模擬器無窮大 - 如何獲取和使用皇家鑰匙
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
北端:融合系統,解釋
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆樹的耳語 - 如何解鎖抓鉤
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Java教學
1666
14
CakePHP 教程
1426
52
Laravel 教程
1328
25
PHP教程
1273
29
C# 教程
1253
24
探究C++sort函數的底層原理與演算法選擇 探究C++sort函數的底層原理與演算法選擇 Apr 02, 2024 pm 05:36 PM

C++sort函數底層採用歸併排序,其複雜度為O(nlogn),並提供不同的排序演算法選擇,包括快速排序、堆排序和穩定排序。

uniapp中如何實現拖曳排序與拖曳操作 uniapp中如何實現拖曳排序與拖曳操作 Oct 19, 2023 am 09:39 AM

Uniapp是一款跨平台的開發框架,其強大的跨端能力使得開發者可以快速方便地開發出各種應用。在Uniapp中實現拖曳排序和拖曳操作也是非常簡單的,並且可以支援多種組件和元素的拖曳操作。本文將介紹如何使用Uniapp實作拖曳排序和拖曳操作,並提供具體的程式碼範例。拖曳排序功能在許多應用中都非常常見,例如可以用於實現清單的拖曳排序,圖示的拖曳排序等。下面我們以列表

time包的單調時鐘處理 time包的單調時鐘處理 Aug 04, 2023 pm 05:45 PM

我們今天主要是來看看golang time 套件的時間應用方式。兩者的一般規則是“wall time”用於告知時間,而“monotonic clock”用於測量時間;除外還有其他的時鐘處理方式。

使用C#中的Array.Sort函數對陣列進行排序 使用C#中的Array.Sort函數對陣列進行排序 Nov 18, 2023 am 10:37 AM

標題:C#中使用Array.Sort函數對陣列進行排序的範例正文:在C#中,陣列是一種常用的資料結構,經常需要對陣列進行排序運算。 C#提供了Array類,其中有Sort方法可以方便地對陣列進行排序。本文將示範如何使用C#中的Array.Sort函數對陣列進行排序,並提供具體的程式碼範例。首先,我們要先了解Array.Sort函數的基本用法。 Array.So

Laravel 集合中的 Where 方法實用指南 Laravel 集合中的 Where 方法實用指南 Mar 10, 2024 pm 04:36 PM

Laravel集合中的Where方法實用指南在Laravel框架的開發過程中,集合(Collection)是一個非常有用的資料結構,它提供了豐富的方法來操作資料。其中,Where方法是常用的篩選方法,能夠根據指定條件來過濾集合中的元素。本文將介紹Laravel集合中Where方法的使用,透過具體的程式碼範例來示範其用法。 1.基本用法Where方法的

Vue專案中如何實現資料的分頁與顯示最佳化 Vue專案中如何實現資料的分頁與顯示最佳化 Oct 15, 2023 am 09:27 AM

Vue專案中實現資料的分頁和顯示優化在Vue專案中,當頁面需要展示大量資料時,通常需要進行資料的分頁和顯示最佳化以提高使用者體驗,本文將介紹如何使用Vue實現資料的分頁和顯示最佳化,並提供具體的程式碼範例。一、資料分頁資料分頁是指將大量資料依照一定的規則分割成多頁,並在頁面上進行分頁顯示。 Vue專案中可以使用下列步驟來實現資料分頁:定義資料來源首先,定義一個包含所有數

為什麼在Python中list.sort()不會傳回已排序的清單? 為什麼在Python中list.sort()不會傳回已排序的清單? Sep 18, 2023 am 09:29 AM

範例在這個範例中,我們先來看看list.sort()的用法,然後再繼續。在這裡,我們建立了一個清單並使用sort()方法按升序排序-#CreatingaListmyList=["Jacob","Harry","Mark","Anthony"]#DisplayingtheListprint("List=",myList)#SorttheListsinAscendingOrdermyList .sort(

PHP8.1新增的數字排序函數 PHP8.1新增的數字排序函數 Jul 09, 2023 pm 10:07 PM

PHP8.1新增的數位排序函數PHP是一種廣泛使用的開源腳本語言,常用於Web開發。它不僅功能強大,還擁有豐富的內建函數庫。在最近發布的PHP8.1版本中,又新增了一些有趣的特性和函數,其中包含了數字排序函數。這些新函數可以使開發者更方便地對數字數組進行排序操作,提高開發效率和程式碼可讀性。在過去的PHP版本中,我們通常會使用sort()或rsort()函數對數

See all articles