leblanc-simon / OpenSondage

Fork de STUdS
70 stars 36 forks source link

Compatibilité Postgresql des suppressions jointurées #21

Closed jpguerard closed 12 years ago

jpguerard commented 13 years ago

La suppression des sondages utilise des DELETE avec des jointures (LEFT INNER JOIN).

Ce type de suppression n'est pas compatible avec Postgresql.

Le correctif suivant devrait corriger ce problème :

diff -rBbu /home/fevrier/OpenSondage//admin/index.php OpenSondage//admin/index.php
--- /home/fevrier/OpenSondage//admin/index.php  2011-07-31 21:13:39.000000000 +0000
+++ OpenSondage//admin/index.php    2011-07-31 21:19:24.000000000 +0000
@@ -84,13 +84,13 @@
     $date=date('H:i:s d/m/Y');

     // requetes SQL qui font le ménage dans la base
-    $connect->Execute('DELETE FROM sondage LEFT INNER JOIN sujet_studs ON sujet_studs.id_sondage = sondage.id_sondage '.
-                      'LEFT INNER JOIN user_studs ON user_studs.id_sondage = sondage.id_sondage ' .
-                      'LEFT INNER JOIN comments ON comments.id_sondage = sondage.id_sondage ' .
-                      "WHERE id_sondage = '$dsondage->id_sondage' ");
+    $connect->Execute("DELETE FROM sujet_studs WHERE id_sondage = '$dsondage->id_sondage'; " .
+                      "DELETE FROM user_studs  WHERE id_sondage = '$dsondage->id_sondage'; " .
+                      "DELETE FROM comments    WHERE id_sondage = '$dsondage->id_sondage'; " .
+                      "DELETE FROM sondage     WHERE id_sondage = '$dsondage->id_sondage'; " );

     // ecriture des traces dans le fichier de logs
    error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\t$nbuser\t$dsujets->sujet\n", 'logs_studs.txt');
   }

   $i++;
diff -rBbu /home/fevrier/OpenSondage//adminstuds.php OpenSondage//adminstuds.php
--- /home/fevrier/OpenSondage//adminstuds.php   2011-07-31 21:13:40.000000000 +0000
+++ OpenSondage//adminstuds.php 2011-07-31 21:17:23.000000000 +0000
@@ -271,13 +271,12 @@
   $date=date('H:i:s d/m/Y:');

   //destruction des données dans la base SQL
-  $sql  = 'DELETE FROM sondage     WHERE id_sondage = '.$connect->Param('numsondage')."; ";
-  $sql .= 'DELETE FROM sujet_studs WHERE id_sondage = '.$connect->Param('numsondage')."; ";
-  $sql .= 'DELETE FROM user_studs  WHERE id_sondage = '.$connect->Param('numsondage')."; ";
-  $sql .= 'DELETE FROM comments    WHERE id_sondage = '.$connect->Param('numsondage');
+  $sql .= "DELETE FROM sujet_studs WHERE id_sondage = '$connect->Param('numsondage')'; ";
+  $sql .= "DELETE FROM user_studs  WHERE id_sondage = '$connect->Param('numsondage')'; ";
+  $sql .= "DELETE FROM comments    WHERE id_sondage = '$connect->Param('numsondage')'; ";
+  $sql  = "DELETE FROM sondage     WHERE id_sondage = '$connect->Param('numsondage')'";
   $sql = $connect->Prepare($sql);
   if ($connect->Execute($sql, array($numsondage))) {
-
     // on ecrit dans le fichier de logs la suppression du sondage
     error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\t$nbuser\t$dsujets->sujet\n", 3, 'admin/logs_studs.txt');

diff -rBbu /home/fevrier/OpenSondage//scripts/nettoyage_sondage.php OpenSondage//scripts/nettoyage_sondage.php
--- /home/fevrier/OpenSondage//scripts/nettoyage_sondage.php    2011-07-31 21:13:40.000000000 +0000
+++ OpenSondage//scripts/nettoyage_sondage.php  2011-07-31 21:20:52.000000000 +0000
@@ -49,10 +49,11 @@
 while ($dsondage=$sondage->FetchNextObject(false)) {
   if ($date_courante > strtotime($dsondage->date_fin)) {
     //destruction des données dans la base
-    $connect->Execute('DELETE FROM sondage LEFT INNER JOIN sujet_studs ON sujet_studs.id_sondage = sondage.id_sondage '.
-                      'LEFT INNER JOIN user_studs ON user_studs.id_sondage = sondage.id_sondage ' .
-                      'LEFT INNER JOIN comments ON comments.id_sondage = sondage.id_sondage ' .
-                      "WHERE id_sondage = '$dsondage->id_sondage' ");
+    $connect->Execute("DELETE FROM comments    WHERE id_sondage = '$dsondage->id_sondage'; " .
+                      "DELETE FROM sujet_studs WHERE id_sondage = '$dsondage->id_sondage'; " .
+                      "DELETE FROM user_studs  WHERE id_sondage = '$dsondage->id_sondage'; " .
+                      "DELETE FROM sondage     WHERE id_sondage = '$dsondage->id_sondage'; " );
+
     // ecriture des traces dans le fichier de logs
     error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", '../admin/logs_studs.txt');
   }
leblanc-simon commented 12 years ago

corrigé par le commit de fevrier, voir #41