Skip to content
Snippets Groups Projects
Commit a6e6298f authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Meilleure info sur les MAJ en direct

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