Commit a6e6298f authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Meilleure info sur les MAJ en direct

parent a2c03d48
......@@ -207,8 +207,10 @@ class Table
public function merge(array $data, $key, array $options = [])
public function merge(array $data, $key, array $options = []): array
{
$result = ['insert' => 0, 'update' => 0, 'delete' => 0];
/* Initialisation */
$defaultOptions = [
'where' => null,
......@@ -258,10 +260,12 @@ class Table
if (empty($old)) { // INSERT
if ($options['insert']) {
$this->insert($new);
$result['insert'] ++;
}
} elseif (empty($new)) { // DELETE
if ($options['delete']) {
$this->delete($this->makeKeyArray($old, $key));
$result['delete'] ++;
}
} elseif ($options['update']) { // UPDATE si différent!!
$toUpdate = [];
......@@ -276,9 +280,12 @@ class Table
}
if (!empty($toUpdate)) {
$this->update($toUpdate, $this->makeKeyArray($old, $key));
$result['update'] ++;
}
}
}
return $result;
}
......
......@@ -377,9 +377,6 @@ class DataGen
$hasHisto = isset($ddl['columns']['HISTO_CREATION']) && isset($ddl['columns']['HISTO_MODIFICATION']) && isset($ddl['columns']['HISTO_DESTRUCTION']);
$hasImport = isset($ddl['columns']['SOURCE_ID']) && isset($ddl['columns']['SOURCE_CODE']);
echo $table . "\n"; // provisoire
//$this->oseAdmin->getConsole()->println($tbl);
if (method_exists($this, $table)) {
$data = $this->$table();
} elseif (array_key_exists($table, $this->nomenclature)) {
......@@ -418,12 +415,15 @@ class DataGen
}
}
$tableObject->merge(
echo str_pad($table, 31, ' '); // provisoire
//$this->oseAdmin->getConsole()->println($tbl);
$result = $tableObject->merge(
$data,
isset($params['key']) ? $params['key'] : 'ID',
isset($params['options']) ? $params['options'] : []
);
echo 'Insert: '.$result['insert'].', Update: '.$result['update'].', Delete: '.$result['delete'];
echo "\n";
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment