insert($params); } elseif(strtoupper($mode{0}) == "D"){ $this->delete(); } elseif(strtoupper($mode{0}) == "U"){ $this->update($params); } else{ error_log("Monster_Collection_Handler::__construct : Unknown mode " + $mode); $this->response = 400; } } private function insert($params){ $s = "INSERT INTO monster_collection (monster, stars, level, awaken) VALUES( " . $params["monster"] . ", " . $params["stars"] . ", " . $params["level"] . ", " . $params["awaken"] . " " . "); "; if ($this->db->exec($s)){ $this->response = 200; } else{ error_log("Monster_Collection_Handler::insert : Query error for --" + $s + "-- " + mysqli_error($this->db)); $this->response = 400; } } private function delete(){ $s = "UPDATE monster_collection SET " . " stars = 0, " . " level = 0, " . " awaken = 0 " . "WHERE id = " . $this->entity->id . "; "; if ($this->db->exec($s)){ $this->response = 200; } else{ error_log("Monster_Collection_Handler::delete : Query error for --" + $s + "-- " + mysqli_error($this->db)); $this->response = 400; } } private function update($params){ if (isset($params["monster"])){ $this->entity->monster = new Monster($params["monster"]); } if (isset($params["stars"])){ $this->entity->stars = $params["stars"]; } if (isset($params["level"])){ $this->entity->level = $params["level"]; } if (isset($params["awaken"])){ $this->entity->awaken = $params["awaken"]; } $s = "UPDATE monster_collection SET " . " monster = " . $this->monster->id . ", " . " stars = " . $this->stars . ", " . " level = " . $this->level . ", " . " awaken = " . $this->awaken . " " . "WHERE id = " . $this->entity->id . "; "; if ($this->db->exec($s)){ $this->response = 200; } else{ error_log("Monster_Collection_Handler::update : Query error for --" + $s + "-- " + mysqli_error($this->db)); $this->response = 400; } } } ?>