db->query($s); $r = $q->fetchArray(SQLITE3_ASSOC); $this->id = $r["id"]; $this->product = new K_Monster($this->db, $r["product"]); $this->product_awaken = new K_Monster($this->db, $this->product->awakens_to); $this->stars = $r["stars"]; $this->cost = $r["cost"]; $s_f = "SELECT DISTINCT " . " ingredient " . "FROM k_fusion " . "WHERE " . " product = " . $this->product->id . " AND " . " ingredient IN ( " . " SELECT DISTINCT k_monster.id " . " FROM " . " k_fusion, " . " k_monster " . " WHERE " . " k_fusion.product = k_monster.awakens_from OR " . " k_fusion.product = k_monster.awakens_to OR " . " k_fusion.product = k_monster.id " . " ); "; $q_f = $this->db->query($s_f); while ($r_f = $q_f->fetchArray(SQLITE3_ASSOC)){ array_push($this->fusion, new Fusion($this->db, $r_f["ingredient"])); } $s_m = "SELECT " . " id, " . " awakens_from " . "FROM k_monster " . "WHERE id IN ( " . " SELECT DISTINCT " . " ingredient " . " FROM k_fusion " . " WHERE " . " product = " . $this->product->id . " AND " . " ingredient NOT IN ( " . " SELECT DISTINCT k_monster.id " . " FROM " . " k_fusion, " . " k_monster " . " WHERE " . " k_fusion.product = k_monster.awakens_from OR " . " k_fusion.product = k_monster.awakens_to OR " . " k_fusion.product = k_monster.id " . " ) " . " ); "; error_log("ING: " . $s_m); $q_m = $this->db->query($s_m); while ($r_m = $q_m->fetchArray(SQLITE3_ASSOC)){ array_push($this->ingredient, new K_Monster($this->db, $r_m["id"])); error_log("NEW awakens_from: " . $r_m["awakens_from"]); array_push($this->ingredient_unawaken, new K_Monster($this->db, $r_m["awakens_from"])); } } } ?>