Add class NodaDbAdmin
This commit is contained in:
parent
831dbca091
commit
cb6d0d7b06
53
src/NodaDbAdmin.php
Normal file
53
src/NodaDbAdmin.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?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'");
|
||||
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'");
|
||||
MDConsole::write("Create table `" . $index_name . "`");
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user