go("SELECT codice FROM b_enti WHERE db = 'W'")->fetchAll(PDO::FETCH_ASSOC); if (!empty($enti)) { $found = []; $updateStato = $pdo->prepare("UPDATE b_enti SET db = :stato WHERE codice = :codice"); foreach($enti AS $ente) { $updateStato->bindValue(":codice",$ente["codice"]); if ($pdo->go("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '{$config["prefix_db"]}_ente{$ente["codice"]}'")->rowCount() === 0) { shell_exec("php {$config["cmds_folder"]}/artisan tenantdb:create {$ente["codice"]} --force 2>&1"); } if ($pdo->go("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '{$config["prefix_db"]}_ente{$ente["codice"]}'")->rowCount() === 0) { $updateStato->bindValue(":stato","E"); $mailer = new Communicator(); $mailer->oggetto = "ERRORE CREAZIONE DB" . $ente["codice"]; $mailer->corpo = "ERRORE CREAZIONE DB" . $ente["codice"]; $mailer->codice_pec = -2; $mailer->comunicazione = false; $mailer->coda = false; $mailer->intestazione = false; $mailer->destinatari = "assistenza@studioamica.it"; $esito = $mailer->send(); alertManager::printCliAlert($mailer->oggetto); } else { $updateStato->bindValue(":stato","S"); } $updateStato->execute(); } } } ?>