public function Connection::nextIdDelete

1 call to Connection::nextIdDelete()
Connection::__destruct in drupal/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php

File

drupal/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php, line 186
Definition of Drupal\Core\Database\Driver\mysql\Connection

Class

Connection

Namespace

Drupal\Core\Database\Driver\mysql

Code

public function nextIdDelete() {

  // While we want to clean up the table to keep it up from occupying too
  // much storage and memory, we must keep the highest value in the table
  // because InnoDB  uses an in-memory auto-increment counter as long as the
  // server runs. When the server is stopped and restarted, InnoDB
  // reinitializes the counter for each table for the first INSERT to the
  // table based solely on values from the table so deleting all values would
  // be a problem in this case. Also, TRUNCATE resets the auto increment
  // counter.
  try {
    $max_id = $this
      ->query('SELECT MAX(value) FROM {sequences}')
      ->fetchField();

    // We know we are using MySQL here, no need for the slower db_delete().
    $this
      ->query('DELETE FROM {sequences} WHERE value < :value', array(
      ':value' => $max_id,
    ));
  } catch (DatabaseException $e) {
  }
}