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));

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

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));