Ignore:
Timestamp:
Oct 16, 2007, 3:46:09 AM (17 years ago)
Author:
rvelices
Message:
  • quick search optimizations (less queries)
  • added some meta_robots (noindex and nofollow) on popuphelp, search_rules and search seaction (googlebot gets crazy)
File:
1 edited

Legend:

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

    r2135 r2138  
    363363 * 'as_is' => 1 (indicates the caller that items are ordered and permissions checked
    364364 * 'qs'    => array(
    365  *    'matching_tags' => array(85,86) - matching tags
    366  *    'matching_cats' => array(1,2,3) - matching categories
     365 *    'matching_tags' => array of matching tags
     366 *    'matching_cats' => array of matching categories
    367367 *    'matching_cats_no_images' =>array(99) - matching categories without images
    368368 *      ))
     
    432432  { // search name and url name (without accents)
    433433    $query = '
    434 SELECT id
     434SELECT id, name, url_name
    435435  FROM '.TAGS_TABLE.'
    436436  WHERE ('.str_replace($q_like_field, 'CONVERT(name, CHAR)', $q_like_clause).'
    437437    OR '.str_replace($q_like_field, 'url_name', $q_like_clause).')';
    438     $tag_ids = array_from_query( $query, 'id');
    439     if (!empty($tag_ids))
     438    $tags = hash_from_query($query, 'id');
     439    if ( !empty($tags) )
    440440    { // we got some tags; get the images
    441       $search_results['qs']['matching_tags']=$tag_ids;
     441      $search_results['qs']['matching_tags']=$tags;
    442442      $query = '
    443443SELECT image_id, COUNT(tag_id) AS weight
    444444  FROM '.IMAGE_TAG_TABLE.'
    445   WHERE tag_id IN ('.implode(',',$tag_ids).')
     445  WHERE tag_id IN ('.implode(',',array_keys($tags)).')
    446446  GROUP BY image_id';
    447447      $result = pwg_query($query);
     
    458458  global $user;
    459459  $query = '
    460 SELECT id, nb_images
     460SELECT id, name, permalink, nb_images
    461461  FROM '.CATEGORIES_TABLE.'
    462462    INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON id=cat_id
     
    471471    if ($row['nb_images']==0)
    472472    {
    473       $search_results['qs']['matching_cats_no_images'][] = $row['id'];
     473      $search_results['qs']['matching_cats_no_images'][] = $row;
    474474    }
    475475    else
    476476    {
    477       $search_results['qs']['matching_cats'][] = $row['id'];
     477      $search_results['qs']['matching_cats'][$row['id']] = $row;
    478478    }
    479479  }
     
    495495  {
    496496    $where_clauses[]='category_id IN ('.
    497       implode(',',$search_results['qs']['matching_cats']).')';
     497      implode(',',array_keys($search_results['qs']['matching_cats'])).')';
    498498  }
    499499  $where_clauses = array( '('.implode("\n    OR ",$where_clauses).')' );
Note: See TracChangeset for help on using the changeset viewer.