<?php

/**
 * Created by PhpStorm.
 * User: rdok
 * Date: 10/15/2014
 * Time: 10:52 PM
 */
require __DIR__ . '/../app/init.php';
$reports = ReportFetcher::retrieveAll();
foreach ($reports as $report) {
    $reportId = $report[ReportFetcher::DB_COLUMN_ID];
    if (!StudentBroughtAlongFetcher::exists($reportId)) {
        StudentBroughtAlongFetcher::insert($reportId);
    }
    if (!PrimaryFocusOfConferenceFetcher::exists($reportId)) {
        PrimaryFocusOfConferenceFetcher::insert($reportId);
    }
    if (!ConclusionWrapUpFetcher::exists($reportId)) {
        ConclusionWrapUpFetcher::insert($reportId);
    }
}
Esempio n. 2
0
 public static function insert($studentId, $appointmentId, $instructorId)
 {
     try {
         $query = "INSERT INTO `" . App::getDbName() . "`.`" . self::DB_TABLE . "`\n\t\t\t(`" . self::DB_COLUMN_STUDENT_ID . "`,\t`" . self::DB_COLUMN_INSTRUCTOR_ID . "`)\n\t\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t:student_id,\n\t\t\t\t\t:instructor_id\n\t\t\t\t)";
         $dbConnection = DatabaseManager::getConnection();
         $dbConnection->beginTransaction();
         $query = $dbConnection->prepare($query);
         $query->bindParam(':student_id', $studentId, PDO::PARAM_INT);
         $query->bindParam(':instructor_id', $instructorId, PDO::PARAM_INT);
         $query->execute();
         // last inserted if of THIS connection
         $reportId = $dbConnection->lastInsertId();
         StudentBroughtAlongFetcher::insert($reportId);
         PrimaryFocusOfConferenceFetcher::insert($reportId);
         ConclusionWrapUpFetcher::insert($reportId);
         AppointmentHasStudentFetcher::update($appointmentId, $reportId);
         $dbConnection->commit();
         return $reportId;
     } catch (Exception $e) {
         if (isset($dbConnection)) {
             $dbConnection->rollback();
         }
         Mailer::sendDevelopers($e->getMessage(), __FILE__);
         throw new Exception("Could not insert data into database.");
     }
 }