当前位置: 首页>>代码示例>>PHP>>正文


PHP CGlobal::allCategories方法代码示例

本文整理汇总了PHP中CGlobal::allCategories方法的典型用法代码示例。如果您正苦于以下问题:PHP CGlobal::allCategories方法的具体用法?PHP CGlobal::allCategories怎么用?PHP CGlobal::allCategories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGlobal的用法示例。


在下文中一共展示了CGlobal::allCategories方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCats

 static function getCats($update_cache = 0, $delcache = false)
 {
     if (!CGlobal::$allCategories || $delcache || $update_cache) {
         if (AZArrCache::is_not_cached('cat_arr', 0, '', $delcache)) {
             if (!$delcache) {
                 $re = DB::query("SELECT zoneid, catid,category_zone_cat.position FROM category_zone_cat LEFT JOIN category_zone ON category_zone_cat.zoneid = category_zone.id ORDER BY category_zone.position,category_zone_cat.position");
                 $cat_zones = array();
                 $allZoneCats = array();
                 if ($re) {
                     while ($zcat = mysql_fetch_assoc($re)) {
                         $allZoneCats[$zcat['zoneid']][$zcat['catid']] = $zcat['catid'];
                         $cat_zones[$zcat['catid']][$zcat['zoneid']] = $zcat['zoneid'];
                     }
                 }
                 $re = DB::query('SELECT id, name, brief_name, total_item, position, class  FROM category_zone WHERE status=1 ORDER BY position', __LINE__ . __FILE__);
                 if ($re) {
                     while ($zone = mysql_fetch_assoc($re)) {
                         $zone['ebname'] = AZLib::safe_title($zone['name']);
                         if (isset($allZoneCats[$zone['id']])) {
                             $zone['cats'] = $allZoneCats[$zone['id']];
                         } else {
                             $zone['cats'] = array();
                         }
                         CGlobal::$allZones[$zone['id']] = $zone;
                     }
                 }
                 $re = DB::query('SELECT id,ref_id, name, brief_name, status, parent_id, keywords, description, position, tag_search, img_server, price_str, recomend FROM category WHERE status!="HIDE" ORDER BY parent_id, position', __LINE__ . __FILE__);
                 if ($re) {
                     while ($cat = mysql_fetch_assoc($re)) {
                         $cat['ebname'] = AZLib::safe_title($cat['name']);
                         $cat['nice_name'] = $cat['ebname'];
                         if ($cat['parent_id']) {
                             //Nếu là danh mục cấp 2
                             if (isset(CGlobal::$allCategories[$cat['parent_id']])) {
                                 //Nếu tồn tại danh mục cha
                                 if ($cat['parent_id'] == 104) {
                                     //Hàng hiệu
                                     $cat['nice_name'] = CGlobal::$allCategories[$cat['parent_id']]['nice_name'] . "-{$cat['ebname']}";
                                 } else {
                                     $cat['nice_name'] = CGlobal::$allCategories[$cat['parent_id']]['nice_name'];
                                 }
                                 if (CGlobal::$allCategories[$cat['parent_id']]['parent_id']) {
                                     //Nếu là danh mục cấp 3
                                     $level2_id = $cat['parent_id'];
                                     $top_id = CGlobal::$allCategories[$cat['parent_id']]['parent_id'];
                                     if (isset(CGlobal::$allCategories[$top_id])) {
                                         //Nếu tồn tại danh mục cha
                                         $cat['nice_name'] = CGlobal::$allCategories[$top_id]['nice_name'];
                                     }
                                 } else {
                                     CGlobal::$subCategories[$cat['parent_id']][$cat['id']] = $cat;
                                 }
                             } else {
                                 CGlobal::$subCategories[$cat['parent_id']][$cat['id']] = $cat;
                             }
                         } elseif (!isset(CGlobal::$subCategories[$cat['id']])) {
                             CGlobal::$subCategories[$cat['id']] = array();
                             if (isset($cat_zones[$cat['id']])) {
                                 $cat['zones'] = $cat_zones[$cat['id']];
                             } else {
                                 $cat['zones'] = array();
                             }
                         }
                         CGlobal::$allCategories[$cat['id']] = $cat;
                     }
                 }
                 AZArrCache::set(array('allZones' => CGlobal::$allZones, 'allCategories' => CGlobal::$allCategories, 'subCategories' => CGlobal::$subCategories));
             } else {
                 /* foreach (CGlobal::$my_server as $server){//Tạo lại file js cho chuyên mục
                    @fopen("http://$server/catgen.php","r");
                    } */
                 // @fopen(WEB_ROOT . "seo.php", "r");
                 /*$js_ver = rand(1, 1000);
                   AZMemcache::do_put("cat_ver:", $js_ver);*/
             }
         } else {
             CGlobal::$allZones = AZArrCache::$arr_cache['allZones'];
             CGlobal::$allCategories = AZArrCache::$arr_cache['allCategories'];
             CGlobal::$subCategories = AZArrCache::$arr_cache['subCategories'];
             AZArrCache::$arr_cache = array();
         }
     }
 }
开发者ID:duynhan07,项目名称:elink,代码行数:83,代码来源:AZLib.php


注:本文中的CGlobal::allCategories方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。