public static function fetchResult(Connection $conn, Area $area, Course $course) { $data = $conn->fetchAssoc('SELECT r.* ' . 'FROM `' . CourseTables::COURSE_RESULT_TBL . '` r ' . 'INNER JOIN `' . CourseTables::COURSE_AREA_RESULT_TBL . '` a ON a.`courseId` = r.`courseId` AND a.`userId` = r.`userId` ' . 'WHERE a.`areaId` = :areaId AND a.`courseId` = :courseId', array(':areaId' => $area->getId(), ':courseId' => $course->getId())); $result = new AreaCourseResult(); $result->area = $area; $result->course = $course; $result->result = Question::RESULT_UNKNOWN; if (false === $data) { return $result; } DataMappers::fromArray($result, $data); return $result; }
public static function fetchResult(Connection $conn, User $user, Course $course) { $data = $conn->fetchAssoc('SELECT * FROM `' . CourseTables::COURSE_RESULT_TBL . '` WHERE `userId` = :userId AND `courseId` = :courseId', array(':userId' => $user->getId(), ':courseId' => $course->getId())); $result = new TestResult(); $result->user = $user; $result->course = $course; $result->result = Question::RESULT_UNKNOWN; if (false === $data) { return $result; } DataMappers::fromArray($result, $data); return $result; }
public function update(Connection $conn) { $groupName = null; if (null !== $this->group) { $groupName = $this->group->getName(); } if (!DataMappers::same($this->oldGroup, $this->group)) { DataMappers::recount($conn, CoreTables::GROUP_TBL, $this->oldGroup, $this->group, 'areaNum', 'id'); } if (!DataMappers::same($this->oldStatus, $this->status)) { DataMappers::recount($conn, CoreTables::AREA_STATUS_TBL, $this->oldStatus, $this->status, 'areaNum', 'id'); } if (!DataMappers::same($this->oldTerritory, $this->territory)) { DataMappers::recount($conn, CoreTables::TERRITORY_TBL, $this->oldTerritory, $this->territory, 'areaNum', 'id'); } $this->entity->setName($this->name); $this->entity->update($conn); $this->lastUpdatedAt = time(); return $conn->update(CoreTables::AREA_TBL, DataMappers::pick($this, ['name', 'group', 'territory', 'status', 'lastUpdatedAt', 'percentCompleteness'], ['customData' => json_encode($this->customData), 'groupName' => $groupName]), DataMappers::pick($this, ['id'])); }
public function remove(Connection $conn) { $conn->delete(LinksTables::LINK_TBL, DataMappers::pick($this, ['id'])); }
public function remove(Connection $conn) { $this->removedAt = time(); return $conn->update(CoreTables::ENTITY_TBL, DataMappers::pick($this, ['removedAt']), DataMappers::pick($this, ['id'])); }
public function remove(Connection $conn) { $conn->update(CoreTables::USER_TBL, ['removed' => 1, 'active' => 0, 'name' => '???'], DataMappers::id($this)); $conn->executeQuery('DELETE FROM `' . CoreTables::USER_PROFILE_TBL . '` WHERE `userId` = :id', [':id' => $this->getId()]); }
public function insert(Connection $conn) { if (null !== $this->getId()) { throw new LogicException('Cannot perform insert() on a persisted Course instance.'); } $this->lastUpdated = time(); $conn->insert(CourseTables::COURSE_TBL, DataMappers::pick($this, ['name', 'description', 'project', 'authorName', 'authorEmail', 'lastUpdated', 'presentationLink', 'deadline', 'isPublished', 'displayOrder', 'notes'])); $this->setId($conn->lastInsertId()); if ($this->getPublished()) { $this->incrementMandatoryCourses($conn); } return $this->getId(); }
public function setCompletedAt($completedAt) { DataMappers::noOverwritingField($this->completedAt); $this->completedAt = $completedAt; return $this; }
public function remove(Connection $conn) { $conn->delete(ExportTables::DATA_EXPORT_TBL, DataMappers::pick($this, ['id'])); }
public function remove(Connection $conn) { $this->status = $conn->fetchColumn('SELECT `status` FROM `' . CoreTables::AREA_REQUEST_TBL . '` WHERE `id` = :id', [':id' => $this->id]); if ($this->canRemove()) { DataMappers::recount($conn, CoreTables::TERRITORY_TBL, $this->territory, null, 'requestNum', 'id'); $conn->delete(CoreTables::AREA_REQUEST_TBL, DataMappers::pick($this, ['id'])); } }
public function remove(Connection $conn) { $conn->delete(EdkTables::ROUTE_TBL, DataMappers::pick($this, ['id'])); }
public function __construct(ForumRoot $root, ForumParentInterface $parent, array $data) { DataMappers::fromArray($this, $data); $this->setParent($parent); }
public function update(Connection $conn) { $this->entity->setName($this->name); $this->entity->update($conn); return $conn->update(CoreTables::PROJECT_TBL, DataMappers::pick($this, ['name', 'description', 'parentProject', 'areasAllowed', 'areaRegistrationAllowed', 'archived', 'archivedAt'], ['modules' => implode(',', $this->getModules())]), DataMappers::pick($this, ['id'])); }
public function setId($id) { DataMappers::noOverwritingId($this->id); $this->id = $id; return $this; }
public function remove(Connection $conn) { $conn->delete(CoreTables::AREA_STATUS_TBL, DataMappers::pick($this, ['id'])); }
public function remove(Connection $conn) { $this->areaNum = $conn->fetchColumn('SELECT `areaNum` FROM `' . CoreTables::TERRITORY_TBL . '` WHERE `id` = :id', [':id' => $this->id]); if ($this->canRemove()) { $conn->delete(CoreTables::TERRITORY_TBL, DataMappers::pick($this, ['id'])); return true; } return false; }
public function remove(Connection $conn) { $conn->delete(CoreTables::USER_REGISTRATION_TBL, DataMappers::pick($this, ['id'])); }
public function remove(Connection $conn) { $conn->delete(CoreTables::LANGUAGE_TBL, DataMappers::pick($this, ['id'])); }
public function changeState(Connection $conn) { $conn->update(EdkTables::MESSAGE_TBL, DataMappers::pick($this, ['status', 'answeredAt', 'completedAt', 'responder', 'duplicate']), ['id' => $this->id]); }
public function remove(Connection $conn) { $conn->delete(MilestoneTables::MILESTONE_RULE_TBL, DataMappers::pick($this, ['id'])); }
public function remove(Connection $conn) { if ($this->canRemove()) { $this->entity->remove($conn); $conn->delete(CoreTables::GROUP_TBL, DataMappers::pick($this, ['id'])); } }
public function setEntity($entity) { DataMappers::noOverwritingField($this->entity); $this->entity = $entity; return $this; }
public function update(Connection $conn) { $conn->update(EdkTables::PARTICIPANT_TBL, DataMappers::pick($this, ['firstName', 'lastName', 'sex', 'age', 'email', 'peopleNum', 'customAnswer', 'whyParticipate', 'howManyTimes', 'whereLearnt', 'whereLearntOther']), ['id' => $this->id]); }
public function remove(Connection $conn) { $conn->delete(CoreTables::GROUP_CATEGORY_TBL, DataMappers::pick($this, ['id'])); }
public function update(Connection $conn) { if ($this->isNew) { $conn->insert(EdkTables::REGISTRATION_SETTINGS_TBL, DataMappers::pick($this, ['route', 'registrationType', 'startTime', 'endTime', 'externalRegistrationUrl', 'participantLimit', 'allowLimitExceed', 'maxPeoplePerRecord', 'externalParticipantNum', 'customQuestion'], ['areaId' => $this->route->getArea()->getId()])); } else { $conn->update(EdkTables::REGISTRATION_SETTINGS_TBL, DataMappers::pick($this, ['registrationType', 'startTime', 'endTime', 'externalRegistrationUrl', 'participantLimit', 'allowLimitExceed', 'maxPeoplePerRecord', 'externalParticipantNum', 'customQuestion']), ['routeId' => $this->route->getId()]); } $conn->update(EdkTables::ROUTE_TBL, ['updatedAt' => time()], ['id' => $this->route->getId()]); return $this->route->getId(); }