<?php
class SQLGroupByWeeks
{
  static public function group(CDbCriteria $dbCriteria, $timeFieldName)
  {
    $groupBy  =  "YEAR(".$timeFieldName.")";
    $groupBy .=  ",";
    $groupBy .=  "WEEKOFYEAR(".$timeFieldName.")";

    $dbCriteria->mergeWith(array('group' => $groupBy));
    return $dbCriteria;
  }
}
