values = $values; } ////////////////////////////////////////////////////////////////////////////// public function getDateStart() { return new Date($this->get('date_start')); } public function getDateEnd() { return new Date($this->get('date_end')); } public function getDescription() { return $this->get('description'); } private function get($key) { if (!empty($this->values[$key])) { return $this->values[$key]; } else { return ''; } } public function getId() { return $this->get('id'); } /////////////////////////////////////////////////////////////////////////////// function setDateStart($date_start) { $this->values['date_start'] = $date_start; } function setDateEnd($date_end) { $this->values['date_end'] = $date_end; } function setDescription($description) { $this->values['description'] = $description; } function setId($id) { $this->values['id'] = $id; } /////////////////////////////////////////////////////////////////////////////// public function save($gateway) { if ($this->get('id')) { $gateway->update($this->values, array('id' => $this->get('id'))); } else { $gateway->insert($this->values); } return true; } //////////////////////////////////////////////////////////////////// // TODO should be in a gateway public static function getFromId($conn, $id) { try { //$result = $conn->query('SELECT * FROM langtkursus_fag_periode WHERE id = ' . $conn->quote((int)$id)); $result = $conn->query('SELECT * FROM langtkursus_fag_periode WHERE id = ' . $conn->quote((int)$id))->fetchAll(PDO::FETCH_ASSOC); } catch (Exception $e) { throw $e; } return new VIH_Course_Period($result[0]); } //////////////////////////////////////////////////////////////////// public function addSubject($subject) { $this->subjects[] = $subject; } public function getSubjects() { return $this->subjects; } }