/** * Saves information about a timesheet in the database table * @param Timesheet $timesheet The timesheet to save in the database */ private function saveDatabase(Timesheet $timesheet) { $db = $this->getDB(); $userID = $timesheet->getTutorID(); $dateCreated = $timesheet->getDateCreated(); $filename = $timesheet->getFilename(); // Deletes duplicate timesheets generated the same day by the same user $query = "DELETE FROM " . self::TABLE_TIMESHEET . " WHERE userID = '" . $userID . "' AND dateCompleted = '" . $dateCreated . "'"; $db->query($query); $save = array(); $save['userID'] = $userID; $save['dateCompleted'] = $dateCreated; $save['filename'] = $filename; $db->insert(self::TABLE_TIMESHEET, $save); }