function _drush_sql_drop

6.x sql.drush.inc _drush_sql_drop($db_spec = NULL)
4.x sql.drush.inc _drush_sql_drop($db_spec = NULL)
5.x sql.drush.inc _drush_sql_drop($db_spec = NULL)
2 calls to _drush_sql_drop()
drush_sql_drop in commands/sql/sql.drush.inc
Drops all tables in the database.
drush_sql_empty_db in commands/sql/sql.drush.inc
Drop all tables (if DB exists) or CREATE target database.

File

commands/sql/sql.drush.inc, line 974
Drush sql commands

Code

function _drush_sql_drop($db_spec = NULL) {
  $tables = _drush_sql_get_db_table_list($db_spec);
  $scheme = _drush_sql_get_scheme($db_spec);
  if (count($tables)) {
    if ($scheme === 'sqlite') {
      $sql = '';
      // SQLite only wants one table per DROP TABLE command (so we have to do
      // "DROP TABLE foo; DROP TABLE bar;" instead of "DROP TABLE foo, bar;").
      foreach ($tables as $table) {
        $sql .= "DROP TABLE $table; ";
      }
      // We can't use drush_op('db_query', $sql) because it will only perform one
      // SQL command and we're technically performing several.
      $exec = _drush_sql_connect($db_spec);
      $exec .= " '{$sql}'";
      return drush_op_system($exec) == 0;
    }
    else {
      $sql = 'DROP TABLE ' . implode(', ', $tables);
      return _drush_sql_query($sql, $db_spec);
    }
  }
  else {
    drush_log(dt('No tables to drop.'), 'ok');
  }
  return TRUE;
}