I'm wondering how to programmatically truncate a table in drupal8.
Is this possible?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
Sure, the function still exists: https://api.drupal.org/api/drupal/core%21includes%21database.inc/function/db_truncate/8.5.x.
It's deprecated, though, with the advice:
Instead, get a database connection injected into your service from the container and call
truncate()on it. For example,
If you're not in a context where injection is possible, get it from