function Schema::findTables

Same name in this branch
  1. 11.x core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema::findTables()
  2. 11.x core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::findTables()
Same name and namespace in other branches
  1. 9 core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::findTables()
  2. 9 core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema::findTables()
  3. 9 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::findTables()
  4. 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php \Drupal\Core\Database\Driver\sqlite\Schema::findTables()
  5. 8.9.x core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php \Drupal\Core\Database\Driver\pgsql\Schema::findTables()
  6. 8.9.x core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::findTables()
  7. 10 core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::findTables()
  8. 10 core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema::findTables()
  9. 10 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::findTables()

Overrides Schema::findTables

File

core/modules/sqlite/src/Driver/Database/sqlite/Schema.php, line 807

Class

Schema
SQLite implementation of <a href="/api/drupal/core%21lib%21Drupal%21Core%21Database%21Schema.php/class/Schema/11.x" title="Provides a base implementation for Database Schema." class="local">\Drupal\Core\Database\Schema</a>.

Namespace

Drupal\sqlite\Driver\Database\sqlite

Code

public function findTables($table_expression) {
    $tables = [];
    // The SQLite implementation doesn't need to use the same filtering strategy
    // as the parent one because individually prefixed tables live in their own
    // schema (database), which means that neither the main database nor any
    // attached one will contain a prefixed table name, so we just need to loop
    // over all known schemas and filter by the user-supplied table expression.
    $attached_dbs = $this->connection
        ->getAttachedDatabases();
    foreach ($attached_dbs as $schema) {
        // Can't use query placeholders for the schema because the query would
        // have to be :prefixsqlite_master, which does not work. We also need to
        // ignore the internal SQLite tables.
        $result = $this->connection
            ->query("SELECT name FROM [" . $schema . "].sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", [
            ':type' => 'table',
            ':table_name' => $table_expression,
            ':pattern' => 'sqlite_%',
        ]);
        $tables += $result->fetchAllKeyed(0, 0);
    }
    return $tables;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.