Commit 7082f4e4 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Paramètres plus fins pour la MAJ de données

parent 04da8df6
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -240,7 +240,9 @@ class Table
            'delete'             => true,
            'insert'             => true,
            'update'             => true,
            'update-cols'        => [],
            'update-ignore-cols' => [],
            'update-only-null'   => [],
        ];
        $options        = array_merge($defaultOptions, $options);

@@ -300,10 +302,18 @@ class Table
                    $oldc = isset($old[$c]) ? $old[$c] : null;
                    if ($newc instanceof \DateTime) $newc = $newc->format('Y-m-d');
                    if ($oldc instanceof \DateTime) $oldc = $oldc->format('Y-m-d');
                    if (!in_array($c, $options['update-ignore-cols']) && $c != 'ID' && array_key_exists($c, $new) && $newc !== $oldc) {
                    if ($newc !== $oldc && array_key_exists($c, $new) && $c != 'ID') {
                        $ok = empty($options['update-cols']); // OK par défaut si une liste n'a pas été établie manuellement

                        if (in_array($c, $options['update-cols'])) $ok = true;
                        if (in_array($c, $options['update-ignore-cols'])) $ok = false;
                        if (in_array($c, $options['update-only-null']) && $oldc !== null) $ok = false;

                        if ($ok) {
                            $toUpdate[$c] = $new[$c];
                        }
                    }
                }
                if (!empty($toUpdate)) {
                    $this->update($toUpdate, $this->makeKeyArray($old, $key), $traitementOptions);
                    $result['update']++;
+4 −1
Original line number Diff line number Diff line
@@ -190,7 +190,10 @@ class DataGen
            'table'   => 'ETAT_SORTIE',
            'context' => ['install', 'update'],
            'key'     => 'CODE',
            'options' => ['update' => false, 'delete' => false],
            'options' => ['update'           => true, 'delete' => false,
                          'update-cols'      => ['CSV_PARAMS', 'CSV_TRAITEMENT', 'PDF_TRAITEMENT'],
                          'update-only-null' => ['CSV_PARAMS', 'CSV_TRAITEMENT', 'PDF_TRAITEMENT'],
            ],
        ],
        [
            'table'   => 'MODELE_CONTRAT',