PostgreSQL compatibility: suppress JOIN in DELETE

This commit is contained in:
Jean-Philippe Guérard 2011-12-29 18:57:49 +01:00
parent 63837ebd55
commit 5f1825179a
3 changed files with 16 additions and 31 deletions

View File

@ -87,15 +87,10 @@ while($dsondage = $sondage->FetchNextObject(false)) {
// On inclut la routine de suppression
$date=date('H:i:s d/m/Y');
$req = 'DELETE s, su, u, c
FROM
sondage s LEFT JOIN sujet_studs su
ON su.id_sondage = s.id_sondage
LEFT JOIN user_studs u
ON u.id_sondage = s.id_sondage
LEFT JOIN comments c
ON c.id_sondage = s.id_sondage
WHERE s.id_sondage = '.$connect->Param('id_sondage');
$req = 'DELETE FROM sujet_studs WHERE id_sondage = ' . $connect->Param('id_sondage') . '; ' .
'DELETE FROM user_studs WHERE id_sondage = ' . $connect->Param('id_sondage') . '; ' .
'DELETE FROM comments WHERE id_sondage = ' . $connect->Param('id_sondage') . '; ' .
'DELETE FROM sondage WHERE id_sondage = ' . $connect->Param('id_sondage') ;
$sql = $connect->Prepare($req);
$connect->Execute($sql, array($dsondage->id_sondage));
@ -152,4 +147,4 @@ echo '</html>'."\n";
// si on annule la suppression, rafraichissement de la page
if (issetAndNoEmpty('annulesuppression') === true) {
}
}

View File

@ -314,15 +314,11 @@ if (isset($_POST["confirmesuppression"]) || isset($_POST["confirmesuppression_x"
$date=date('H:i:s d/m/Y:');
//destruction des données dans la base SQL
$sql = 'DELETE s, su, u, c
FROM
sondage s LEFT JOIN sujet_studs su
ON su.id_sondage = s.id_sondage
LEFT JOIN user_studs u
ON u.id_sondage = s.id_sondage
LEFT JOIN comments c
ON c.id_sondage = s.id_sondage
WHERE s.id_sondage = '.$connect->Param('numsondage');
$sql = 'DELETE FROM sujet_studs WHERE id_sondage = ' . $connect->Param('numsondage') . '; ' .
'DELETE FROM user_studs WHERE id_sondage = ' . $connect->Param('numsondage') . '; ' .
'DELETE FROM comments WHERE id_sondage = ' . $connect->Param('numsondage') . '; ' .
'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
@ -1257,4 +1253,4 @@ echo '<div class="separateur">&nbsp;</div>';
bandeau_pied_mobile();
echo '</form>'."\n";
echo '</body>'."\n";
echo '</html>'."\n";
echo '</html>'."\n";

View File

@ -49,16 +49,10 @@ $sondage=$connect->Execute("select * from sondage");
while ($dsondage=$sondage->FetchNextObject(false)) {
if ($date_courante > strtotime($dsondage->date_fin)) {
//destruction des données dans la base
$req = 'DELETE s, su, u, c
FROM
sondage s LEFT JOIN sujet_studs su
ON su.id_sondage = s.id_sondage
LEFT JOIN user_studs u
ON u.id_sondage = s.id_sondage
LEFT JOIN comments c
ON c.id_sondage = s.id_sondage
WHERE s.id_sondage = '.$connect->Param('id_sondage');
$req = 'DELETE FROM sujet_studs WHERE id_sondage = ' . $connect->Param('id_sondage') . '; ' .
'DELETE FROM user_studs WHERE id_sondage = ' . $connect->Param('id_sondage') . '; ' .
'DELETE FROM comments WHERE id_sondage = ' . $connect->Param('id_sondage') . '; ' .
'DELETE FROM sondage WHERE id_sondage = ' . $connect->Param('id_sondage') ;
$sql = $connect->Prepare($req);
$connect->Execute($sql, array($dsondage->id_sondage));
@ -66,4 +60,4 @@ while ($dsondage=$sondage->FetchNextObject(false)) {
// 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", 3, '../admin/logs_studs.txt');
}
}
}