mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-18 12:30:35 +01:00
Fix parziale #203
This commit is contained in:
parent
b43cee9c24
commit
30024fd353
@ -27,7 +27,12 @@ if (post('db_host') !== null) {
|
|||||||
$valid_config = isset($db_host) && isset($db_name) && isset($db_username) && isset($db_password);
|
$valid_config = isset($db_host) && isset($db_name) && isset($db_username) && isset($db_password);
|
||||||
|
|
||||||
// Generazione di una nuova connessione al database
|
// Generazione di una nuova connessione al database
|
||||||
$dbo = Database::getConnection(true);
|
$dbo = Database::getConnection(true, [
|
||||||
|
'db_host' => $db_host,
|
||||||
|
'db_name' => $db_name,
|
||||||
|
'db_username' => $db_username,
|
||||||
|
'db_password' => $db_password,
|
||||||
|
]);
|
||||||
|
|
||||||
// Test della configurazione
|
// Test della configurazione
|
||||||
if (post('test') !== null) {
|
if (post('test') !== null) {
|
||||||
|
@ -116,13 +116,16 @@ class Database extends Util\Singleton
|
|||||||
*
|
*
|
||||||
* @return Database
|
* @return Database
|
||||||
*/
|
*/
|
||||||
public static function getConnection($new = false)
|
public static function getConnection($new = false, $data = [])
|
||||||
{
|
{
|
||||||
$class = get_called_class();
|
$class = get_called_class();
|
||||||
|
|
||||||
if (empty(parent::$instance[$class]) || !parent::$instance[$class]->isConnected() || $new) {
|
if (empty(parent::$instance[$class]) || !parent::$instance[$class]->isConnected() || $new) {
|
||||||
$config = App::getConfig();
|
$config = App::getConfig();
|
||||||
|
|
||||||
|
// Sostituzione degli eventuali valori aggiuntivi
|
||||||
|
$config = array_merge($config, $data);
|
||||||
|
|
||||||
parent::$instance[$class] = new self($config['db_host'], $config['db_username'], $config['db_password'], $config['db_name']);
|
parent::$instance[$class] = new self($config['db_host'], $config['db_username'], $config['db_password'], $config['db_name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user