/**
  * Counts number of unique values that match a specific criterium
  * @param Interval $interval
  * @return array List of unique values
  */
 public function uniqueValues($interval, $listable = true, $count = 2)
 {
     $uniqueValues = array();
     if (!$listable) {
         return $uniqueValues;
     }
     $this->connect();
     $sql = $this->match;
     $sql = str_replace("@period", "BETWEEN '" . $interval->getStartTS("YmdHis") . "' AND '" . $interval->getEndTS("YmdHis") . "' ", $sql);
     $sql = str_replace("@start", " '" . $interval->getStartTS("YmdHis") . "' ", $sql);
     $sql = str_replace("@end", " '" . $interval->getEndTS("YmdHis") . "' ", $sql);
     //echo '<br>'.$sql;
     $res = mysql_query($sql);
     if (!$res) {
         return $uniqueValues;
     }
     while ($row = mysql_fetch_array($res)) {
         $rowArr = array();
         for ($i = 0; $i < $count; $i++) {
             $rowArr[] = $row[$i];
         }
         $uniqueValues[] = $rowArr;
     }
     return $uniqueValues;
 }
 /**
  * Counts number of unique values that match a specific criterium
  * @param Interval $interval
  * @return array List of unique values
  */
 public function uniqueValues($interval, $listable = true, $count = 2)
 {
     $uniqueValues = array();
     if (!$listable) {
         return $uniqueValues;
     }
     $this->connect();
     $sql = $this->match;
     $sql = str_replace("@period", "BETWEEN '" . $interval->getStartTS("Y-m-d H:i:s+00") . "' AND '" . $interval->getEndTS("Y-m-d H:i:s+00") . "' ", $sql);
     $sql = str_replace("@start", " '" . $interval->getStartTS("Y-m-d H:i:s+00") . "' ", $sql);
     $sql = str_replace("@end", " '" . $interval->getEndTS("Y-m-d H:i:s+00") . "' ", $sql);
     $sql = str_replace("stats_ts", "to_timestamp(stats_ts,'YYYYMMDDHH24MISS')", $sql);
     $res = pg_query($this->conn, $sql);
     while ($row = pg_fetch_array($res)) {
         $rowArr = array();
         for ($i = 0; $i < $count; $i++) {
             $rowArr[] = $row[$i];
         }
         $uniqueValues[] = $rowArr;
     }
     return $uniqueValues;
 }