Loading src/UnicaenSynchro/Service/SqlHelper/SqlHelperService.php +6 −11 Original line number Diff line number Diff line Loading @@ -104,8 +104,7 @@ class SqlHelperService } public function update(EntityManager $entityManager, string $table, array $item, array $correspondance, string $id, ?string $source = null): void public function update(EntityManager $entityManager, string $table, array $item, array $correspondance, string $primarykey_id, string $id, ?string $source = null): void { $values = []; foreach ($correspondance as $s => $d) { Loading @@ -113,23 +112,19 @@ class SqlHelperService } if ($source !== null) $values[] = "source_id='" . $source . "'"; $values[] = "updated_on=now()"; $sql = "update " . $table . " set " . implode(" , ", $values) . " where id=:id"; $sql = "update " . $table . " set " . implode(" , ", $values) . " where ".$primarykey_id."=:id"; $this->executeRequeteRef($entityManager, $sql, ["id" => $id]); } public function restore(EntityManager $entityManager, string $table, string $id): void public function restore(EntityManager $entityManager, string $table, string $primarykey_id, string $id): void { $sql = "update " . $table . " set deleted_on=NULL where id=:id"; $sql = "update " . $table . " set deleted_on=NULL where ".$primarykey_id."=:id"; $this->executeRequeteRef($entityManager, $sql, ["id" => $id]); } public function delete(EntityManager $entityManager, string $table, string $id): void public function delete(EntityManager $entityManager, string $table, string $primarykey_id, string $id): void { $sql = "update " . $table . " set deleted_on=now() where id=:id"; $sql = "update " . $table . " set deleted_on=now() where ".$primarykey_id."=:id"; $this->executeRequeteRef($entityManager, $sql, ["id" => $id]); } } No newline at end of file src/UnicaenSynchro/Service/Synchronisation/SynchronisationService.php +4 −3 Original line number Diff line number Diff line Loading @@ -144,6 +144,7 @@ class SynchronisationService $orm_destination = $this->entityManagers[$this->getFromConfig($name, 'orm_destination')]; $table_destination = $this->getFromConfig($name, 'table_destination'); $source = $this->getFromConfig($name, 'source'); $primarykey_id = $this->getFromConfig($name, 'id'); $debut = new DateTime(); Loading @@ -167,7 +168,7 @@ class SynchronisationService if ($item['deleted_on'] === null && !isset($data_source[$id])) { $nbRetrait++; // $texte_retrait .= "Retrait de ".$id." des données destination.\n"; $this->getSqlHelperService()->delete($orm_destination, $table_destination, $id); $this->getSqlHelperService()->delete($orm_destination, $table_destination, $primarykey_id, $id); } } Loading Loading @@ -196,7 +197,7 @@ class SynchronisationService if (isset($data_destination[$id]) and $data_destination[$id]["deleted_on"] !== null) { $nbRestauration++; // $texte_restauration .= "Restauration de ".$id." des données destinations.\n"; $this->getSqlHelperService()->restore($orm_destination, $table_destination, $id); $this->getSqlHelperService()->restore($orm_destination, $table_destination, $primarykey_id, $id); } } echo "#Restauration: " . $nbRestauration . "\n"; Loading @@ -210,7 +211,7 @@ class SynchronisationService if (isset($data_destination[$id]) and $this->checkDifferences($item, $data_destination[$id], $correspondance, $source)) { $nbModification++; // $texte_modication .= "Modif de ".$id." des données sources.\n"; $this->getSqlHelperService()->update($orm_destination, $table_destination, $item, $correspondance, $id, $source); $this->getSqlHelperService()->update($orm_destination, $table_destination, $item, $correspondance, $primarykey_id, $id, $source); } } echo "#Modification: " . $nbModification . "\n"; Loading Loading
src/UnicaenSynchro/Service/SqlHelper/SqlHelperService.php +6 −11 Original line number Diff line number Diff line Loading @@ -104,8 +104,7 @@ class SqlHelperService } public function update(EntityManager $entityManager, string $table, array $item, array $correspondance, string $id, ?string $source = null): void public function update(EntityManager $entityManager, string $table, array $item, array $correspondance, string $primarykey_id, string $id, ?string $source = null): void { $values = []; foreach ($correspondance as $s => $d) { Loading @@ -113,23 +112,19 @@ class SqlHelperService } if ($source !== null) $values[] = "source_id='" . $source . "'"; $values[] = "updated_on=now()"; $sql = "update " . $table . " set " . implode(" , ", $values) . " where id=:id"; $sql = "update " . $table . " set " . implode(" , ", $values) . " where ".$primarykey_id."=:id"; $this->executeRequeteRef($entityManager, $sql, ["id" => $id]); } public function restore(EntityManager $entityManager, string $table, string $id): void public function restore(EntityManager $entityManager, string $table, string $primarykey_id, string $id): void { $sql = "update " . $table . " set deleted_on=NULL where id=:id"; $sql = "update " . $table . " set deleted_on=NULL where ".$primarykey_id."=:id"; $this->executeRequeteRef($entityManager, $sql, ["id" => $id]); } public function delete(EntityManager $entityManager, string $table, string $id): void public function delete(EntityManager $entityManager, string $table, string $primarykey_id, string $id): void { $sql = "update " . $table . " set deleted_on=now() where id=:id"; $sql = "update " . $table . " set deleted_on=now() where ".$primarykey_id."=:id"; $this->executeRequeteRef($entityManager, $sql, ["id" => $id]); } } No newline at end of file
src/UnicaenSynchro/Service/Synchronisation/SynchronisationService.php +4 −3 Original line number Diff line number Diff line Loading @@ -144,6 +144,7 @@ class SynchronisationService $orm_destination = $this->entityManagers[$this->getFromConfig($name, 'orm_destination')]; $table_destination = $this->getFromConfig($name, 'table_destination'); $source = $this->getFromConfig($name, 'source'); $primarykey_id = $this->getFromConfig($name, 'id'); $debut = new DateTime(); Loading @@ -167,7 +168,7 @@ class SynchronisationService if ($item['deleted_on'] === null && !isset($data_source[$id])) { $nbRetrait++; // $texte_retrait .= "Retrait de ".$id." des données destination.\n"; $this->getSqlHelperService()->delete($orm_destination, $table_destination, $id); $this->getSqlHelperService()->delete($orm_destination, $table_destination, $primarykey_id, $id); } } Loading Loading @@ -196,7 +197,7 @@ class SynchronisationService if (isset($data_destination[$id]) and $data_destination[$id]["deleted_on"] !== null) { $nbRestauration++; // $texte_restauration .= "Restauration de ".$id." des données destinations.\n"; $this->getSqlHelperService()->restore($orm_destination, $table_destination, $id); $this->getSqlHelperService()->restore($orm_destination, $table_destination, $primarykey_id, $id); } } echo "#Restauration: " . $nbRestauration . "\n"; Loading @@ -210,7 +211,7 @@ class SynchronisationService if (isset($data_destination[$id]) and $this->checkDifferences($item, $data_destination[$id], $correspondance, $source)) { $nbModification++; // $texte_modication .= "Modif de ".$id." des données sources.\n"; $this->getSqlHelperService()->update($orm_destination, $table_destination, $item, $correspondance, $id, $source); $this->getSqlHelperService()->update($orm_destination, $table_destination, $item, $correspondance, $primarykey_id, $id, $source); } } echo "#Modification: " . $nbModification . "\n"; Loading