/**
  * @brief Saves all reports to database.
  *
  * ## Overview
  * This will loop through each report and save it to the database as `PerformanceMetrics` in 
  * the `performance_audit`.`metrics` table.
  *
  * @uses PerformanceAuditor->save()
  * @see PerformanceAuditManager->generateReport();
  *
  * @return {Array} Metrics derived from audit reports' data.
  *
  * @author <*****@*****.**>
  * @date 02/19/2014
  */
 public function generateReport($criteria)
 {
     $caller = get_called_class();
     $entries = array();
     $results = array();
     $db = PerformanceMetric::GetDB();
     if ($db) {
         $query = "SELECT `id` FROM `" . PerformanceMetric::_TABLE . "` WHERE `source` = '" . $caller::ID . "'";
         $where = array();
         if (is_array($criteria)) {
             if (isset($criteria["from"])) {
                 $where["`created` >= ?"] = date("Y-m-d H:i:s", strtotime($criteria["from"]));
             }
             if (isset($criteria["to"])) {
                 $where["`created` <= ?"] = date("Y-m-d H:i:s", strtotime($criteria["to"]));
             }
             if (count($where)) {
                 $query .= " AND " . implode(" AND ", array_keys($where));
             }
         }
         // error_log("Executing query: " . $query);
         // error_log("Executing keys: " . implode(",", array_values($where)));
         $statement = $db->prepare($query);
         $statement->execute(array_values($where));
         $entries = $statement->fetchAll(PDO::FETCH_ASSOC);
     } else {
     }
     foreach ($entries as $entry) {
         $results[] = new PerformanceMetric($entry["id"]);
     }
     return array("total" => count($results), "reports" => $results);
 }