7

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

1 Answer 1

15

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 and acknowledge you have read our privacy policy.

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