*/ if (!file_exists(__DIR__ . '/../conf/dbsToCompare.php')) return; /** * Function to connect to all versions to compare the current one with. * Returns an array of database connections. * * @return array */ function connectToCompareDBs():array { include __DIR__ . '/../conf/dbsToCompare.php'; if (empty($dbsToCompare)) return []; $connections = []; foreach ($dbsToCompare as $key => $db) { $connections[$key] = md_mysqli_connect($db['hostname'], $db['username'], $db['password'], $db['databasename']); if (mysqli_connect_error()) { throw new Exception("Error connecting to database " . $db['hostname']); } } return $connections; } /** * Checks the number a given set of times appeared in eveents in a given version. * * @param array $connections Array of DB connections from which to query. * @param integer $timeID ID of the time entry to check. * @param string $currentSubset Name of the current version. * * @return array{0: integer, 1: integer} */ function checkTimes(array $connections, int $timeID, string $currentSubset):array { list($numberofusage, $currentAmount) = [[], 0]; // Set defaults foreach ($connections as $dbName => $connection) { $eergebnis = $connection->do_read_query("SELECT 1 FROM `ereignis` WHERE `zeiten_id` = " . $connection->escape_string((string)$timeID) . " LIMIT 2"); $numberofusage[$dbName] = $anzahl_ergebnis = $eergebnis->num_rows; if (strtolower($dbName) == strtolower($currentSubset)) $currentAmount = $anzahl_ergebnis; $eergebnis->close(); unset($eergebnis); } return [(int)array_sum($numberofusage), $currentAmount]; } /** * Checks the number a given person / institution appeared in events across versions. * * @param array $connections Array of DB connections from which to query. * @param integer $timeID ID of the time entry to check. * @param string $currentSubset Name of the current version. * * @return array{0: integer, 1: integer} */ function checkPersinst(array $connections, int $timeID, string $currentSubset):array { list($numberofusage, $currentAmount) = [[], 0]; // Set defaults foreach ($connections as $dbName => $connection) { $eergebnis = $connection->do_read_query("SELECT 1 FROM `ereignis` WHERE `persinst_id` = " . $connection->escape_string((string)$timeID) . " LIMIT 2"); $numberofusage[$dbName] = $anzahl_ergebnis = $eergebnis->num_rows; if (strtolower($dbName) == strtolower($currentSubset)) $currentAmount = $anzahl_ergebnis; $eergebnis->close(); unset($eergebnis); } return [(int)array_sum($numberofusage), $currentAmount]; } /** * Checks the number a given place appeared in events across versions. * * @param array $connections Array of DB connections from which to query. * @param integer $timeID ID of the time entry to check. * @param string $currentSubset Name of the current version. * * @return array{0: integer, 1: integer} */ function checkPlace(array $connections, int $timeID, string $currentSubset):array { list($numberofusage, $currentAmount) = [[], 0]; // Set defaults foreach ($connections as $dbName => $connection) { $eergebnis = $connection->do_read_query("SELECT 1 FROM `ereignis` WHERE `orte_id` = " . $connection->escape_string((string)$timeID) . " LIMIT 2"); $numberofusage[$dbName] = $anzahl_ergebnis = $eergebnis->num_rows; if (strtolower($dbName) == strtolower($currentSubset)) $currentAmount = $anzahl_ergebnis; $eergebnis->close(); unset($eergebnis); } return [(int)array_sum($numberofusage), $currentAmount]; } /** * Checks the number a given tag appeared in events across versions. * * @param array $connections Array of DB connections from which to query. * @param integer $tagID ID of the tag entry to check. * @param string $currentSubset Name of the current version. * * @return array{0: integer, 1: integer} */ function checkTag(array $connections, int $tagID, string $currentSubset):array { list($numberofusage, $currentAmount) = [[], 0]; // Set defaults foreach ($connections as $dbName => $connection) { $eergebnis = $connection->do_read_query("SELECT 1 FROM `v_objekt_tag2` WHERE `tag_id` = " . $connection->escape_string((string)$tagID) . " LIMIT 2"); $numberofusage[$dbName] = $anzahl_ergebnis = $eergebnis->num_rows; if (strtolower($dbName) == strtolower($currentSubset)) $currentAmount = $anzahl_ergebnis; $eergebnis->close(); unset($eergebnis); } return [(int)array_sum($numberofusage), $currentAmount]; }