id = $id; } $this->load($this->id); } function load($id = NULL) { if (is_numeric($id)) { $this->id = $id; } $ret = false; if (is_numeric($this->id)) { $q = "SELECT * FROM " . DB_PREFIX . "user_exercise_series WHERE id=".$this->id; $ret = query_row($q); } if ( $ret) { $this->id = $ret->id; $this->number = $ret->number; $this->repetitions = $ret->repetitions; $this->kg = $ret->kg; } } function getId() { return $this->id; } function create() { $this->setCreator(get_logged_in_user()->getId()); $q = "INSERT INTO " . DB_PREFIX . "user_exercise_series (creator, exercise, number, repetitions, kg) values (".$this->getCreator().", ".$this->getExercise().", ".$this->getNumber().", '".$this->getRepetitions()."', '".$this->getKG()."')"; $uid = query_insert($q); if ($uid) return $uid; return false; } function save() { $update = query_update("UPDATE " . DB_PREFIX . "user_exercise_series SET repetitions=".$this->getRepetitions().", kg='".$this->getKG()."' WHERE id=".$this->getId()); return $this->getId(); } function build($data) { $this->setRepetitions($data["repetitions"]); $this->setKG($data["kg"]); if ($this->getId() > 0) { return $this->save(); } else { $id = $this->create(); return $id; } } function delete() { global $TeKe; if (is_numeric($this->getId()) && $this->getId() > 0) { if ($TeKe->is_logged_in()) { return query("DELETE FROM " . DB_PREFIX . "examinees WHERE id=".$this->getId()); } } return false; } function getCreator() { return $this->creator; } function setCreator($creator) { $this->creator = $creator; } function getExercise() { return $this->exercise; } function setExercise($exercise) { $this->exercise = $exercise; } function getNumber() { return $this->number; } function setNumber($number) { $this->number = $number; } function getRepetitions() { return $this->repetitions; } function setRepetitions($repetitions) { $this->repetitions = $repetitions; } function getKG() { return $this->kg; } function setKG($kg) { $this->kg = $kg; } } ?>