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
Branches
Tags 8.1beta
No related merge requests found
......@@ -32,6 +32,9 @@ class DataService
foreach ($preparedTablesMetadata as $tableName => $columnsConfig) {
$outputFilePath = sprintf($outputFilePathTemplate, $tableName);
$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);
$sqlSelect = "SELECT * FROM $tableName";
try {
......
......@@ -59,6 +59,7 @@ class SchemaService
throw new RuntimeException("Erreur!", null, $e);
}
$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 = str_replace("\"$srcSchemaName\"", "\"$dstSchemaName\"", $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