/** * Load a specific database table into memory. * * @param string $tableName * @return DriverTable * @author Anthony Bush **/ public function loadTable($tableName) { $table = new MysqlTable($tableName, $this->dbLink, $this); $table->loadColumns(); $this->tables[$tableName] = $table; return $table; }
$courseNames->setInfoArray($infoToSet); ProjectFunctions::assertAndPrint($courseNames->commit(), $courseNames); $courseAreas = new MysqlTable($mysqli, 'course_areas'); ProjectFunctions::assertAndPrint(addCourseItemsMappings($courseAreas, $existingEvaluationId, 'area', $courseInfo['areas']), $courseAreas); $courseSkills = new MysqlTable($mysqli, 'course_skills'); ProjectFunctions::assertAndPrint(addCourseItemsMappings($courseSkills, $existingEvaluationId, 'skill', $courseInfo['skills']), $courseSkills); $courseProfessors = new MysqlTable($mysqli, 'course_professors'); ProjectFunctions::assertAndPrint(addCourseItemsMappings($courseProfessors, $existingEvaluationId, 'professor', $courseInfo['professors']), $courseProfessors); if ($courseInfo['exam']['group'] !== 0) { $examGroups = new MysqlTable($mysqli, 'exam_groups'); $infoToSet = extractFieldsFromArray(array('date', 'time'), $courseInfo['exam']); $infoToSet['id'] = $courseInfo['exam']['group']; $examGroups->setInfoArray($infoToSet); ProjectFunctions::assertAndPrint($examGroups->commit(), $examGroups); } $courseSessions = new MysqlTable($mysqli, 'course_sessions'); $courseSessions->addCond('course_id', $existingEvaluationId); ProjectFunctions::assertAndPrint($courseSessions->executeDeleteQuery(), $courseSessions); $courseSessions->clearSelect(); $courseSessions->setInfo('course_id', $existingEvaluationId); foreach ($courseInfo['sessions'] as &$session) { $infoToSet = extractFieldsFromArray(array('start_time', 'end_time', 'location'), $session); $infoToSet['course_id'] = $existingEvaluationId; foreach ($session['days'] as &$day) { $infoToSet['day_of_week'] = $day; $courseSessions->setInfoArray($infoToSet); ProjectFunctions::assertAndPrint($courseSessions->commit(), $courseSessions); } } $courseFlags = new MysqlTable($mysqli, 'course_flags'); ProjectFunctions::assertAndPrint(addCourseItemsMappings($courseFlags, $existingEvaluationId, 'flag', $courseInfo['extra_flags']), $courseFlags);
} } $evaluationInfo['comments'] = array(); foreach ($commentPages as &$qidNumber) { $page = $curl->fetchPageAndLogin("https://faculty.yale.edu/viewevals/Search/ViewAnswersByQuestion?subType=all&ap=0&qid={$qidPrefixes[$type]}{$qidNumber}&na=10000", null, false, true); if (empty($page)) { continue; } $comments = getCommentsFromPage($page); if (!empty($comments)) { $evaluationInfo['comments'][(int) $qidNumber] = $comments; } } // This part commits to the database $existingEvaluationId = false; $courseNames = new MysqlTable($mysqli, 'evaluation_course_names'); foreach ($evaluationInfo['courses'] as &$course) { $courseNames->retrieve(array('subject', 'number', 'section', 'season'), array($course['subject'], $course['number'], $course['section'], $season), array('course_id')); if ($courseNames->resultsExist) { $existingEvaluationId = $courseNames->info['course_id']; break; } } $courses = new MysqlTable($mysqli, 'evaluation_courses'); $infoToSet = $evaluationInfo['statistics']; $infoToSet['season'] = $evaluationInfo['season']; if ($existingEvaluationId) { $infoToSet['id'] = $existingEvaluationId; } $courses->setInfoArray($infoToSet); ProjectFunctions::assertAndPrint($courses->commit(), $courses);