static function activate() { // Update the root item. This is a quick hack because the search module is activated as part // of the official install, so this way we don't start off with a "your index is out of date" // banner. search::update(model_cache::get("item", 1)); search::check_index(); }
static function install() { $version = module::get_version("search"); $db = Database::instance(); if ($version == 0) { $db->query("CREATE TABLE `search_records` (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9),\n `dirty` boolean default 1,\n `data` LONGTEXT default NULL,\n PRIMARY KEY (`id`),\n FULLTEXT INDEX (`data`))\n ENGINE=MyISAM DEFAULT CHARSET=utf8;"); // populate the index with dirty records $db->query("insert into `search_records` (`item_id`) SELECT `id` FROM `items`"); module::set_version("search", 1); if (ORM::factory("search_record")->count_all() < 10) { foreach (ORM::factory("search_record")->where("dirty", 1)->find_all() as $record) { search::update_record($record); } } else { search::check_index(); } } }