Ignore:
Timestamp:
Dec 20, 2004, 11:25:05 PM (19 years ago)
Author:
plg
Message:
  • for searching in sub-categories, use the existing get_subcat_ids function
  • bug fixed : category total elements count for best rated when $userforbidden_categories is not empty
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_category.inc.php

    r647 r652  
    512512          {
    513513            // searching all the categories id of sub-categories
    514             $search_cat_clauses = array();
    515             foreach ($search['fields']['cat']['words'] as $cat_id)
    516             {
    517               $local_clause = 'uppercats REGEXP \'(^|,)'.$cat_id.'(,|$)\'';
    518               array_push($search_cat_clauses, $local_clause);
    519             }
    520             array_walk($search_cat_clauses,
    521                        create_function('&$s', '$s = "(".$s.")";'));
    522            
    523             $query = '
    524 SELECT DISTINCT(id) AS id
    525   FROM '.CATEGORIES_TABLE.'
    526   WHERE '.implode(' OR ', $search_cat_clauses).'
    527 ;';
    528             $result = pwg_query($query);
    529             $cat_ids = array();
    530             while ($row = mysql_fetch_array($result))
    531             {
    532               array_push($cat_ids, $row['id']);
    533             }
    534             $local_clause = 'category_id IN (';
    535             $local_clause.= implode(',',$cat_ids);
    536             $local_clause.= ')';
    537             array_push($clauses, $local_clause);
     514            $cat_ids = get_subcat_ids($search['fields']['cat']['words']);
    538515          }
    539516          else
    540517          {
    541             $local_clause = 'category_id IN (';
    542             $local_clause.= implode(',',$search['fields']['cat']['words']);
    543             $local_clause.= ')';
    544             array_push($clauses, $local_clause);
    545           }
     518            $cat_ids = $search['fields']['cat']['words'];
     519          }
     520         
     521          $local_clause = 'category_id IN ('.implode(',', $cat_ids).')';
     522          array_push($clauses, $local_clause);
    546523        }
    547524
     
    686663SELECT COUNT(1) AS count
    687664  FROM '.IMAGES_TABLE.'
     665    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
    688666  '.$page['where'].'
    689667;';
Note: See TracChangeset for help on using the changeset viewer.