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

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