6

I would like to delete all rows from the database that is older than 1 month. How can I do that in Drupal 8?

DELETE FROM myTable WHERE MyColumn < DATEADD(MONTH, -1, GETDATE())

9

You can do it by using this code

$query = \Drupal::database()->delete('table');
$query->condition('some column', 'some condition');
$query->execute();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.