예제 #1
0
 function school_count_since_date($time)
 {
     $S = new Schools();
     //Best way to connect to database?
     $conn = MongoSingleton::getMongoCon();
     $db = $conn->sublite;
     $emails = $db->emails;
     $cursor = $emails->find();
     $pattern = "/(.*)@(.*)/";
     $schools = array();
     $school_names = array();
     foreach ($cursor as $doc) {
         $success = preg_match($pattern, $doc["email"], $match);
         if ($success && $doc["_id"]->getTimestamp() > $time) {
             $schools[$match[2]] += 1;
         }
     }
     foreach ($schools as $key => $id) {
         if ($S->hasSchoolOf($key)) {
             $school_names[$S->nameOf($key)] += $id;
         } else {
             $school_names[$key] += $id;
         }
     }
     return $school_names;
 }
예제 #2
0
 function school_count_since_date($time)
 {
     $S = new Schools();
     //Best way to connect to database?
     $cursor = $this->dbstudent->emails->find();
     $pattern = "/(.*)@(.*)/";
     $schools = array();
     $school_names = array();
     foreach ($cursor as $doc) {
         $success = preg_match($pattern, $doc["email"], $match);
         if ($success && $doc["_id"]->getTimestamp() > $time) {
             if (array_key_exists($match[2], $schools)) {
                 $schools[$match[2]] += 1;
             } else {
                 $schools[$match[2]] = 1;
             }
         }
     }
     foreach ($schools as $key => $id) {
         if ($S->hasSchoolOf($key)) {
             if (array_key_exists($S->nameOf($key), $school_names)) {
                 $school_names[$S->nameOf($key)] += $id;
             } else {
                 $school_names[$S->nameOf($key)] = $id;
             }
         } else {
             if (array_key_exists($key, $school_names)) {
                 $school_names[$key] += $id;
             } else {
                 $school_names[$key] = $id;
             }
         }
     }
     return $school_names;
 }