public function load() { $success = parent::load(); if ($success) { $user = new User($this->user_id, $this->db); $this->ip = $user->ip; // load tags $sql = "SELECT tags.tag,tags.id FROM `dream_tags` LEFT JOIN tags ON dream_tags.tag_id=tags.id "; $sql .= "WHERE dream_tags.dream_id='" . $this->id . "'"; $result = $this->db->query($sql); $this->tags = array(); while ($row = $result->fetch_assoc()) { $this->tags[] = (object) $row; } // load media $sql = "SELECT * FROM `" . Media::TABLE . "` "; $sql .= "WHERE dream_id='" . $this->id . "'"; $result = $this->db->query($sql); $this->media = array(); while ($row = $result->fetch_assoc()) { $this->media[] = new Media($row['id'], $this->db); } } }