You are here

PgSqlHandler.php in DB Maintenance 8

PgSqlHandler class.

File

src/Module/Db/DbServer/PgSql/PgSqlHandler.php
View source
<?php

/**
 * @file
 * PgSqlHandler class.
 */
namespace Drupal\db_maintenance\Module\Db\DbServer\PgSql;

use Drupal\db_maintenance\Module\Db\DbServer\DbServerHandlerInterface;

/**
 * PgSqlHandler class.
 */
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);
    }
  }

}

Classes

Namesort descending Description
PgSqlHandler PgSqlHandler class.