db_truncate

Definition

db_truncate($table, array $options = array())
drupal/includes/database/database.inc, line 2297

Description

Returns a new TruncateQuery object for the active database.

Parameters

$table The table from which to delete.

$options An array of options to control how the query operates.

Return value

TruncateQuery A new TruncateQuery object for this connection.

Related topics

Namesort iconDescription
Database abstraction layerAllow the use of different database servers using the same code base.

Code

function db_truncate($table, array $options = array()) {
  if (empty($options['target']) || $options['target'] == 'slave') {
    $options['target'] = 'default';
  }
  return Database::getConnection($options['target'])->truncate($table, $options);
}