public function Sqlsqlite::listTables

8.0.x Sqlsqlite.php public Sqlsqlite::listTables()
7.x Sqlsqlite.php public Sqlsqlite::listTables()
master Sqlsqlite.php public Sqlsqlite::listTables()

Extract the name of all existing tables in the given database.

Return value

array An array of table names which exist in the current database.

Overrides SqlBase::listTables

File

lib/Drush/Sql/Sqlsqlite.php, line 50

Namespace

Drush\Sql

Class

Sqlsqlite

Code

public function listTables() {
  $return = $this->query('.tables');
  $tables_raw = drush_shell_exec_output();
  // SQLite's '.tables' command always outputs the table names in a column
  // format, like this:
  // table_alpha    table_charlie    table_echo
  // table_bravo    table_delta      table_foxtrot
  // …and there doesn't seem to be a way to fix that. So we need to do some
  // clean-up.
  foreach ($tables_raw as $line) {
    preg_match_all('/[^\s]+/', $line, $matches);
    if (!empty($matches[0])) {
      foreach ($matches[0] as $match) {
        $tables[] = $match;
      }
    }
  }
  return $tables;
}