diff --git a/src/Table.php b/src/Table.php index 5b148df80d33d883268f23c5468433f45e3d2536..45fff9cd1c4296c504bb59f6bf6ca4e20fde9460 100644 --- a/src/Table.php +++ b/src/Table.php @@ -487,7 +487,7 @@ class Table - public function merge(array $data, $key, array $options = []): array + public function merge(array $data, array|string|null $key, array $options = []): array { $ddl = $this->getDdl(); $bdd = $this->getBdd(); @@ -614,9 +614,9 @@ class Table case 'delete': $callbackCount++; $callbackProgress++; - $key = [$this->makeKeyArray($o, $key)]; - $this->delete($key); - if ($doCallback) call_user_func($callback, 'delete', $callbackProgress, $callbackCount, $o, $key); + $k = $this->makeKeyArray($o, $key); + $this->delete($k); + if ($doCallback) call_user_func($callback, 'delete', $callbackProgress, $callbackCount, $o, $k); break; case 'soft-delete': $toUpdate = [ @@ -625,9 +625,9 @@ class Table ]; $callbackCount++; $callbackProgress++; - $key = $this->makeKeyArray($o, $key); - $this->update($toUpdate, $key, ['ddl' => $ddl]); - if ($doCallback) call_user_func($callback, 'soft-delete', $callbackProgress, $callbackCount, $o, $key); + $k = $this->makeKeyArray($o, $key); + $this->update($toUpdate, $k, ['ddl' => $ddl]); + if ($doCallback) call_user_func($callback, 'soft-delete', $callbackProgress, $callbackCount, $o, $k); break; case 'undelete': $toUpdate = [ @@ -635,9 +635,9 @@ class Table $options['histo-destructeur-id-column'] => null, ]; $callbackProgress++; - $key = $this->makeKeyArray($o, $key); - $this->update($toUpdate, $key, ['ddl' => $ddl]); - if ($doCallback) call_user_func($callback, 'undelete', $callbackProgress, $callbackCount, $o, $key); + $k = $this->makeKeyArray($o, $key); + $this->update($toUpdate, $k, ['ddl' => $ddl]); + if ($doCallback) call_user_func($callback, 'undelete', $callbackProgress, $callbackCount, $o, $k); break; case 'update': $toUpdate = $diff; @@ -646,9 +646,9 @@ class Table $toUpdate[$options['histo-modificateur-id-column']] = $options['histo-user-id']; } $callbackProgress++; - $key = $this->makeKeyArray($o, $key); + $k = $this->makeKeyArray($o, $key); $this->update($toUpdate, $key, ['ddl' => $ddl]); - if ($doCallback) call_user_func($callback, 'update', $callbackProgress, $callbackCount, $toUpdate, $key); + if ($doCallback) call_user_func($callback, 'update', $callbackProgress, $callbackCount, $toUpdate, $k); break; }