$dbh = new PDO("mysql:host={$host};dbname={$dbName};port={$port}", $user, $pass); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); /* Query for all applications with this UID */ $query = "SELECT * FROM Application WHERE uID = :uid ORDER BY time_stamp DESC"; $stmt = $dbh->prepare($query); $stmt->bindParam(':uid', $_SESSION['uid'], PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); //Create an array to hold all of the Application objects $appArray = []; foreach ($result as $row) { //Create a new application object $currentApp = new Application(); //Assign all available variables $currentApp->set_semester($row['semester']); $currentApp->set_year($row['year']); $currentApp->set_uid($row['uID']); $currentApp->set_degree($row['degree']); $currentApp->set_avail_hours($row['avail_hours']); $currentApp->set_addit_details($row['addit_details']); $currentApp->set_promised_aid($row['promised_aid']); $currentApp->set_grad_origin($row['grad_origin']); $currentApp->set_grad_ita($row['grad_ita']); $currentApp->set_time_stamp($row['time_stamp']); //Add the current application to the array $appArray[] = $currentApp; } /* Query for info for previously TA'd courses and add it to the correct Application object */ $prevQuery = "SELECT Courses_Info.number, Courses_Info.name, Courses_Info.blurb,\n\tCourses_Info.department, Prev_TA_Courses.ta_experience, Prev_TA_Courses.time_stamp\n\tFROM (Courses_Info JOIN Prev_TA_Courses\n\tON Courses_Info.number = Prev_TA_Courses.number)\n\tWHERE uID = :uid"; $prevStmt = $dbh->prepare($prevQuery); $prevStmt->bindParam(':uid', $_SESSION['uid'], PDO::PARAM_STR);