Exemplo n.º 1
0
 /**
  * returns instance of the class (Singleton Design Pattern)
  * @return <type>
  */
 public static function get_instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new UPCompDatabase();
     }
     return self::$instance;
 }
Exemplo n.º 2
0
 protected function usersToObjectRate($dbQuery)
 {
     $database = UPCompDatabase::get_instance();
     $qr = $database->executeQuery($dbQuery);
     $eventsList = $qr->getResponseList();
     //rating objects
     if (!$eventsList) {
         //wrong query
         $errLog = ErrorLog::get_instance();
         $errLog->logError("No events of the specified type found, no prediction made", "Standard");
         return false;
     } else {
         while ($record = $database->getNextRow($eventsList)) {
             if (array_key_exists($record["objectID"], $this->objectToScoreArray)) {
                 $objectRating = $this->objectToScoreArray[$record["objectID"]];
             } else {
                 $objectRating = 0;
             }
             if (is_array($this->users) and array_key_exists($record["userID"], $this->users)) {
                 $userImportance = $this->users[$record["userID"]];
             } else {
                 $userImportance = 0;
             }
             $objectRating = $this->ratingAggregation($objectRating, $record["eventValue"], $record["eventType"], $this->eventImportance, $userImportance);
             $this->objectToScoreArray[$record["objectID"]] = $objectRating;
         }
     }
 }