Skip to content
Snippets Groups Projects
Commit 740ab644 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Service de génération d'insert de données: exception si impossible d'ouvrir le fichier de sortie.

parent 6d755b67
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,9 @@ class DataService ...@@ -32,6 +32,9 @@ class DataService
foreach ($preparedTablesMetadata as $tableName => $columnsConfig) { foreach ($preparedTablesMetadata as $tableName => $columnsConfig) {
$outputFilePath = sprintf($outputFilePathTemplate, $tableName); $outputFilePath = sprintf($outputFilePathTemplate, $tableName);
$fh = fopen($outputFilePath, 'w'); $fh = fopen($outputFilePath, 'w');
if ($fh === false) {
throw new RuntimeException("Impossible d'ouvrir en écriture le fichier '$outputFilePath'.");
}
fwrite($fh, "set define off ;" . PHP_EOL . PHP_EOL); fwrite($fh, "set define off ;" . PHP_EOL . PHP_EOL);
$sqlSelect = "SELECT * FROM $tableName"; $sqlSelect = "SELECT * FROM $tableName";
try { try {
......
...@@ -59,6 +59,7 @@ class SchemaService ...@@ -59,6 +59,7 @@ class SchemaService
throw new RuntimeException("Erreur!", null, $e); throw new RuntimeException("Erreur!", null, $e);
} }
$result = $stmt->fetchAll(\PDO::FETCH_COLUMN); $result = $stmt->fetchAll(\PDO::FETCH_COLUMN);
// NB: si le résultat est vide, c'est sans doute un problème de droit du USER Oracle utilisé pour exécuter les commandes
$sql = implode('', $result); $sql = implode('', $result);
$sql = str_replace("\"$srcSchemaName\"", "\"$dstSchemaName\"", $sql); $sql = str_replace("\"$srcSchemaName\"", "\"$dstSchemaName\"", $sql);
file_put_contents($outputFilePath, $sql); file_put_contents($outputFilePath, $sql);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment