Merge pull request #41 from fevrier/postgres_compat

Compatibilité PostgreSQL
This commit is contained in:
Simon Leblanc 2012-01-10 16:46:59 -08:00
commit 526c3bec81
4 changed files with 49 additions and 49 deletions

View File

@ -86,24 +86,16 @@ while($dsondage = $sondage->FetchNextObject(false)) {
if (issetAndNoEmpty('confirmesuppression'.$i) === true) {
// 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');
$sql = $connect->Prepare($req);
$connect->Execute($sql, array($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", 3, 'logs_studs.txt');
if ( remove_sondage( $connect, $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", 3, 'logs_studs.txt');
}
}
$i++;
}
@ -152,4 +144,4 @@ echo '</html>'."\n";
// si on annule la suppression, rafraichissement de la page
if (issetAndNoEmpty('annulesuppression') === true) {
}
}

View File

@ -313,18 +313,7 @@ if (isset($_POST["confirmesuppression"]) || isset($_POST["confirmesuppression_x"
$nbuser=$user_studs->RecordCount();
$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 = $connect->Prepare($sql);
if ($connect->Execute($sql, array($numsondage))) {
if ( remove_sondage( $connect, $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\n", 3, 'admin/logs_studs.txt');
@ -1257,4 +1246,4 @@ echo '<div class="separateur">&nbsp;</div>';
bandeau_pied_mobile();
echo '</form>'."\n";
echo '</body>'."\n";
echo '</html>'."\n";
echo '</html>'."\n";

View File

@ -203,6 +203,33 @@ function getUrlSondage($id, $admin = false)
return $url;
}
function remove_sondage( $connect, $numsondage ){
$connect->StartTrans();
$req = 'DELETE FROM sondage WHERE id_sondage = ' . $connect->Param('numsondage') ;
$sql = $connect->Prepare($req);
$connect->Execute($sql, array($numsondage));
$req = 'DELETE FROM sujet_studs WHERE id_sondage = ' . $connect->Param('numsondage') ;
$sql = $connect->Prepare($req);
$connect->Execute($sql, array($numsondage));
$req = 'DELETE FROM user_studs WHERE id_sondage = ' . $connect->Param('numsondage') ;
$sql = $connect->Prepare($req);
$connect->Execute($sql, array($numsondage));
$req = 'DELETE FROM comments WHERE id_sondage = ' . $connect->Param('numsondage') ;
$sql = $connect->Prepare($req);
$connect->Execute($sql, array( $numsondage ));
$suppression_OK = ! $connect->HasFailedTrans() ;
$connect->CompleteTrans();
return $suppression_OK ;
}
$connect=connexion_base();
@ -216,4 +243,4 @@ define('NO_POLL_ID', 0x0001000000);
define('INVALID_EMAIL', 0x0010000000);
define('TITLE_EMPTY', 0x0100000000);
define('INVALID_DATE', 0x1000000000);
$err = 0;
$err = 0;

View File

@ -49,21 +49,13 @@ $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');
$sql = $connect->Prepare($req);
$connect->Execute($sql, array($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", 3, '../admin/logs_studs.txt');
if ( remove_sondage( $connect, $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", 3, '../admin/logs_studs.txt');
}
}
}
}