コード例 #1
0
 public static function GetDB()
 {
     if (!self::$_db) {
         $creds = self::GetDBCreds();
         self::$_db = new PDO("mysql:host=" . $creds["DB_HOST"] . ";dbname=" . self::_DATABASE, $creds["DB_USER"], $creds["DB_PASS"], array(PDO::ATTR_TIMEOUT, 1));
     }
     return self::$_db;
 }
コード例 #2
0
 public static function GenerateStats(PerformanceMetric $pm, $criteria = null)
 {
     $result = $pm->getValues();
     $result["ho baby"] = "yeah";
     return $result;
 }
コード例 #3
0
 /**
  * @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);
 }
コード例 #4
0
 /**
  * @brief Increment the account audit counter.
  *
  * @uses PerformanceMetricController
  * @uses PerformanceMetricController->save()
  *
  * @return {Null}
  *
  * @author <*****@*****.**>
  * @date 02/19/2014
  */
 public static function Save($report)
 {
     $ah = class_exists("Ontraport") ? Ontraport::GetAccountHandle() : $_SESSION["accountHandle"];
     if ($ah) {
         $report["aid"] = $ah->accountID();
         try {
             $metric = new PerformanceMetric();
             $metric->save($report);
         } catch (Exception $e) {
             self::Warn("perf_metric_save_exception", array("message" => $e->getMessage(), "code" => $e->getCode(), "report" => $report));
         }
     } else {
         if (class_exists("Ontraport")) {
         }
     }
 }