public function get_active_page_version_id($page_path) { if (array_key_exists($page_path, self::$active_version)) { PC::prucpruc('Got cached page version ' . self::$active_version[$page_path] . ' path ' . $page_path); return self::$active_version[$page_path]; } $this->db->where("path", $page_path); $this->db->where("active", "yes"); $query = $this->db->get("page_versions"); $result = $query->result(); if ($result) { PC::prucpruc('Found active version ' . $result[0]->id . " path " . $page_path); self::$active_version[$page_path] = $result[0]->id; return $result[0]->id; } else { $new_version = $this->create_initial_page_version($page_path); PC::prucpruc('New active version ' . $new_version . ' Page ' . $page_path); self::$active_version[$page_path] = $new_version; return $new_version; } }