Changeset 4387


Ignore:
Timestamp:
11/29/09 15:06:16 (10 years ago)
Author:
nikrou
Message:

Feature_1255:

  • bug fix : function pwg_db_get_recent_period_expression
  • add extra fields for select based on "order by"
Location:
trunk/include
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/dblayer/functions_mysql.inc.php

    r4385 r4387  
    459459} 
    460460 
    461 function pwg_db_get_recent_period_expression($period, $date='CURRENT_DATE') 
    462 { 
    463   if ($date!='CURRENT_DATE') 
    464   { 
    465     $date = '\''.$date.'\''; 
    466   } 
    467  
    468   return 'SUBDATE('.$date.',INTERVAL '.$period.' DAY)'; 
    469 } 
    470  
    471 function pwg_db_get_recent_period($period, $date='CURRENT_DATE') 
    472 { 
    473   $query = ' 
    474 SELECT '.pwg_db_get_recent_period_expression($period); 
    475   list($d) = pwg_db_fetch_row(pwg_query($query)); 
    476  
    477   return $d; 
     461function pwg_db_concat_ws($string, $separaor) 
     462{ 
     463  return 'CONCAT_WS(\''.$separaor.'\','. $string.')'; 
     464} 
     465 
     466function pwg_db_cast_to_text($string) 
     467{ 
     468  return 'CAST('.$string.' AS CHAR)'; 
    478469} 
    479470 
  • trunk/include/functions.inc.php

    r4367 r4387  
    3333 
    3434//----------------------------------------------------------- generic functions 
     35function get_extra_fiels($order_by_fields)  
     36{ 
     37  $fields = str_ireplace(array(' order by ', ' desc', ' asc'),  
     38                         array('', '', ''), 
     39                         $order_by_fields 
     40                         ); 
     41  if (!empty($fields)) 
     42  { 
     43    $fields = ','.$fields; 
     44  } 
     45  return $fields; 
     46} 
    3547 
    3648// The function get_moment returns a float value coresponding to the number 
  • trunk/include/functions_tag.inc.php

    r4334 r4387  
    5050  WHERE' 
    5151    ).' 
    52   GROUP BY tag_id 
    53   ORDER BY NULL'; 
     52  GROUP BY tag_id'; 
    5453  $tag_counters = simple_hash_from_query($query, 'tag_id', 'counter'); 
    5554 
     
    235234  } 
    236235  $query .=' 
    237   GROUP BY tag_id'; 
     236  GROUP BY tag_id, t.id, t.name, t.url_name'; 
    238237  if ($max_tags>0) 
    239238  { 
     
    241240  ORDER BY counter DESC 
    242241  LIMIT '.$max_tags; 
    243   } 
    244   else 
    245   { 
    246     $query .= ' 
    247   ORDER BY NULL'; 
    248242  } 
    249243 
  • trunk/include/section_init.inc.php

    r4385 r4387  
    293293    // Main query 
    294294    $query = ' 
    295 SELECT DISTINCT(image_id) 
     295SELECT DISTINCT(image_id)'.get_extra_fields($conf['order_by']).' 
    296296  FROM '.IMAGE_CATEGORY_TABLE.' 
    297297    INNER JOIN '.IMAGES_TABLE.' ON id = image_id 
     
    327327    { 
    328328      $query = ' 
    329 SELECT DISTINCT image_id 
     329SELECT DISTINCT image_id'.get_extra_fields($conf['order_by']).' 
    330330  FROM '.IMAGE_CATEGORY_TABLE.' INNER JOIN '.IMAGES_TABLE.' ON image_id=id 
    331331  WHERE image_id IN ('.implode(',', $items).') 
     
    444444 
    445445    $query = ' 
    446 SELECT DISTINCT(id) 
     446SELECT DISTINCT(id)'.get_extra_fields($conf['order_by'].' 
    447447  FROM '.IMAGES_TABLE.' 
    448448    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 
     
    482482    $conf['order_by'] = ' ORDER BY hit DESC, file ASC'; 
    483483    $query = ' 
    484 SELECT DISTINCT(id) 
     484SELECT DISTINCT(id), hit, file 
    485485  FROM '.IMAGES_TABLE.' 
    486486    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 
     
    509509 
    510510    $query =' 
    511 SELECT DISTINCT(id) 
     511SELECT DISTINCT(id), average_rate 
    512512  FROM '.IMAGES_TABLE.' 
    513513    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 
     
    532532  { 
    533533    $query =' 
    534 SELECT DISTINCT(id) 
     534SELECT DISTINCT(id)'.get_extra_fields($conf['order_by'].' 
    535535  FROM '.IMAGES_TABLE.' 
    536536    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 
Note: See TracChangeset for help on using the changeset viewer.