<?PHP /** * Class for setting up databases. * * @author Joshua Ramon Enslin <joshua@museum-digital.de> */ declare(strict_types = 1); /** * Class for setting up databases. */ final class NodaDbAdmin { /** * Sets up a search index for vocabulary searches. * * @param MDMysqli $mysqli_manticore Manticore DB connection. * @param string $index_name Name of the search index. * * @return void */ public static function resetVocabularySearchIndex(MDMysqli $mysqli_manticore, string $index_name):void { $mysqli_manticore->query("DROP TABLE IF EXISTS `" . $index_name . "`"); $mysqli_manticore->query("CREATE TABLE IF NOT EXISTS `" . $index_name . "` (`entry_id` int, `language` string, `name` text, `description` text, `timestamp` timestamp) min_infix_len = '3' charset_table='" . MDMysqli::MANTICORE_CHARSET_TABLE . "' rt_mem_limit = '2G'"); MDConsole::write("Create table `" . $index_name . "`"); } /** * Ensures that a search index is set up. * * @param MDMysqli $mysqli_manticore Manticore DB connection. * @param string $index_name Name of the search index. * * @return void */ public static function setupVocabularySearchIndex(MDMysqli $mysqli_manticore, string $index_name):void { $mysqli_manticore->query("CREATE TABLE IF NOT EXISTS `" . $index_name . "` (`entry_id` int, `language` string, `name` text, `description` text, `timestamp` timestamp) min_infix_len = '3' expansion_limit = '32' blend_chars = '., :, &, -, ;' blend_mode = 'trim_head, trim_tail, trim_both, trim_all, trim_none, skip_pure' charset_table='" . MDMysqli::MANTICORE_CHARSET_TABLE . "' rt_mem_limit = '2G'"); MDConsole::write("Create table `" . $index_name . "`"); } }