db->query($s); $r = $q->fetchArray(SQLITE3_ASSOC); if ($r){ $this->id = $r["id"]; $this->family = $r["family"]; $this->unit = $r["unit"]; $this->load_skills(); } } /** * Loads the information about the unit skills in the transformed form. */ private function load_skills(){ $this->skill = []; $s = " SELECT skill FROM k_skill, k_unit_skill WHERE id = skill AND unit = " . $this->id . " ORDER BY slot; "; $q = $this->db->query($s); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->skill, new K_Skill($this->db, $r["skill"])); } } /** * Gets the path to the unit image. The image must be in the * img/unit/ directory, and it's name must be the unit id, * padded with '0' to 8 digits, and the extension must be '.png'. * * @return string Image URL, or a fixed unknown image. */ public function get_image(){ return APPLICATION::img("UNIT", $this->id); } } ?>