<?php

class blogMain extends blogBase {

  protected function getActiveBlogSql($activeType, $matchType) {
    switch ($activeType) {
      case 'all':
        return
         "select bl_id, bl_hit from tblblog
          where
          bl_type $matchType
          order by bl_hit desc limit 9";

      case 'week':
        $week = myUtility::dateToWeek(date('Y-m-d'));
        return
         "select std_blog, sum(std_visitors) as s
          from tblblogstatday use index (std_date)
          where
          std_date>='$week' and std_blogtype $matchType
          group by(std_blog)
          order by s desc limit 9";

      case 'day':
        $today = date('Y-m-d');
        return
         "select std_blog, std_visitors from tblblogstatday
          where
          std_date='$today' and std_blogtype $matchType
          order by std_visitors desc limit 9";
    }
  }

  protected function getActiveMemberSql($activeType) {
    switch ($activeType) {
      case 'all':
        return "select us_id, us_score from tbluser order by us_score desc limit 8";

      case 'week':
        $week = myUtility::dateToWeek(date('Y-m-d'));
        return
        "select udsc_user, sum(udsc_score) as scores from tbluserdayscore where udsc_date>='$week' ".
        "group by udsc_user order by scores desc limit 8";

      case 'day':
        $today = date('Y-m-d');
        return
        "select utsc_user, utsc_score from tblusertempscore where utsc_date='$today' ".
        "order by utsc_score desc limit 8";
    }
  }
}
?>
