This topic is locked
[SOLVED]

 After an entry, all data records older than 30 days should be deleted.

12/24/2020 9:59:18 AM
PHPRunner General questions
A
Andreas G. author

How can I do that ?
After Login or after record...
After an entry, all data records older than 30 days should be deleted.
With pypMyAdmin I do it like this:
DELETE FROM contactlist WHERE DATEDIFF (NOW (), date)> = 30

Myr0n 12/24/2020

You can do add that condition in AfterSuccessfulLoginjust I suggest you to add a flag that indicate when was the last time that you check that "all data records older than 30 days should be deleted" to do not requesting too much to your database.

A
Andreas G. author 12/24/2020



You can do add that condition in AfterSuccessfulLoginjust I suggest you to add a flag that indicate when was the last time that you check that "all data records older than 30 days should be deleted" to do not requesting too much to your database.


$sql = "DELETE FROM Kontaktliste WHERE DATEDIFF (NOW (), Kontaktliste.Datum)> 30";
That's not how it works AfterSuccessfulLogin
But it works as a PHP file.
But I do not want that

<?php

require_once ('konfiguration.php');
$db_link = mysqli_connect (

MYSQL_HOST,

MYSQL_BENUTZER,

MYSQL_KENNWORT,

MYSQL_DATENBANK

);


$sql = "DELETE FROM Kontaktliste WHERE DATEDIFF(NOW(), Kontaktliste.Datum) > 30";


$db_erg = mysqli_query( $db_link, $sql );

if ( ! $db_erg )

{

die('Ungueltige Abfrage: ' . mysqli_error());

}




mysqli_free_result( $db_erg );

?>
A
Andreas G. author 12/25/2020

It's been dealt with.

I put it completely in After successful login

without <?php ?>

Seems to work

Myr0n 12/25/2020



It's been dealt with.

I put it completely in After successful login

without <?php ?>

Seems to work


You should use db::delete

You don't need to open a connection to your db

DB::Delete("contactlist", "DATEDIFF (NOW (), date)> = 30" );


A
Andreas G. author 1/15/2021



You should use db::delete

You don't need to open a connection to your db

DB::Delete("contactlist", "DATEDIFF (NOW (), date)> = 30" );



Thanks