You are here

class PgSqlHandler in DB Maintenance 2.0.x

Same name and namespace in other branches
  1. 8 src/Module/Db/DbServer/PgSql/PgSqlHandler.php \Drupal\db_maintenance\Module\Db\DbServer\PgSql\PgSqlHandler
  2. 7.2 src/Module/Db/DbServer/PgSql/PgSqlHandler.php \Drupal\db_maintenance\Module\Db\DbServer\PgSql\PgSqlHandler

PgSqlHandler class.

Hierarchy

Expanded class hierarchy of PgSqlHandler

1 file declares its use of PgSqlHandler
DbServerHandlerFactory.php in src/Module/Db/DbServer/DbServerHandlerFactory.php
DbServerHandlerFactory class.

File

src/Module/Db/DbServer/PgSql/PgSqlHandler.php, line 15
PgSqlHandler class.

Namespace

Drupal\db_maintenance\Module\Db\DbServer\PgSql
View source
class PgSqlHandler implements DbServerHandlerInterface {

  /**
   * Returns list of tables in the active database.
   */
  public function listTables() {
    $result = \Drupal::database()
      ->query("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_name", array(), array(
      'fetch' => \PDO::FETCH_ASSOC,
    ));
    return $result;
  }

  /**
   * Optimizes table in the active database.
   */
  public function optimizeTable($table_name) {
    try {
      \Drupal::database()
        ->query("VACUUM ANALYZE {$table_name}")
        ->execute();
    } catch (\Exception $e) {
      watchdog_exception('type', $e);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PgSqlHandler::listTables public function Returns list of tables in the active database. Overrides DbServerHandlerInterface::listTables
PgSqlHandler::optimizeTable public function Optimizes table in the active database. Overrides DbServerHandlerInterface::optimizeTable