1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-25 15:22:24 +01:00

Introduzione options per connessione al db

This commit is contained in:
Luca 2022-12-05 17:44:20 +01:00
parent d34e77530b
commit d775541f75
3 changed files with 63 additions and 10 deletions

View File

@ -23,6 +23,10 @@ $db_username = '|username|';
$db_password = '|password|';
$db_name = '|database|';
//$port = '|port|';
$db_options = [
//'sort_buffer_size' => '4M',
];
// Percorso della cartella di backup
$backup_dir = __DIR__.'/backup/';

View File

@ -182,29 +182,76 @@ if ($database->isInstalled()){
$db = [
'mysql_version' => [
'type' => 'mysql',
'type' => 'version',
'description' => '5.7.x - 8.0.x',
'minimum' => '5.7.0',
'maximum' => '8.0.99',
],
];
foreach (App::getConfig()['db_options'] as $n => $v){
switch ($n){
case 'sort_buffer_size':
$db[$n] = [
'type' => 'value',
'description' => '>4M',
];
break;
}
}
}
foreach ($db as $name => $values) {
$description = $values['description'];
$description = tr('Valore consigliato: _VALUE_ (Valore attuale: _MYSQL_VERSION_)', [
'_VALUE_' => $description,
'_MYSQL_VERSION_' => $database->getMySQLVersion(),
]);
$status = ((version_compare($database->getMySQLVersion(), $values['minimum'], ">=") && version_compare($database->getMySQLVersion(), $values['maximum'], "<=")) ? 1 : 0);
$description = $values['description'];
if ($values['type'] == 'version') {
$type = tr('Versione');
$description = tr('Valore consigliato: _VALUE_ (Valore attuale: _MYSQL_VERSION_)', [
'_VALUE_' => $description,
'_MYSQL_VERSION_' => $database->getMySQLVersion(),
]);
$status = ((version_compare($database->getMySQLVersion(), $values['minimum'], ">=") && version_compare($database->getMySQLVersion(), $values['maximum'], "<=")) ? 1 : 0);
} else{
$type = tr('Impostazione');
$inc = str_replace(['k', 'M'], ['000', '000000'], App::getConfig()['db_options'][$name]);
$real = str_replace(['k', 'M'], ['000', '000000'], $description);
if (string_starts_with($real, '>')) {
$status = $inc >= substr($real, 1);
} elseif (string_starts_with($real, '<')) {
$status = $inc <= substr($real, 1);
} else {
$status = ($real == $inc);
}
if (is_bool($description)) {
$description = !empty($description) ? 'On' : 'Off';
} else {
$description = str_replace(['>', '<'], '', $description);
}
$description = tr('Valore consigliato: _VALUE_ (Valore attuale: _INI_)', [
'_VALUE_' => $description,
'_INI_' => App::getConfig()['db_options'][$name],
]);
}
$mysql[] = [
'name' => $name,
'description' => $description,
'status' => $status,
'type' => tr('Versione'),
'type' => $type,
];
}
@ -232,7 +279,7 @@ foreach ($dirs_to_check as $name => $description) {
// File di servizio
$files_to_check = [
'manifest.json' => tr('Necessario per aggiunta a schermata home da terminale'),
'manifest.json' => tr('Necessario per l\'aggiunta a schermata home da terminale'),
'database_5_7.json' => tr('Necessario per il controllo integrità con database MySQL 5.7.x'),
'database.json' => tr('Necessario per il controllo integrità con database MySQL 8.0.x'),
'checksum.json' => tr('Necessario per il controllo integrità dei files del gestionale'),

View File

@ -80,9 +80,11 @@ class Database extends Util\Singleton
'database' => $database_name,
'username' => $username,
'password' => $password,
'charset' => 'utf8',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'prefix' => '',
'port' => $port,
'options' => App::getConfig()['db_options'],
]);
$this->is_connected = !empty($this->getPDO());