You are here

public function SiteAuditCheckDatabaseEngine::calculateScore in Site Audit 8.2

Same name and namespace in other branches
  1. 7 Check/Database/Engine.php \SiteAuditCheckDatabaseEngine::calculateScore()

Implements \SiteAudit\Check\Abstract\calculateScore().

Overrides SiteAuditCheckAbstract::calculateScore

File

Check/Database/Engine.php, line 91
Contains \SiteAudit\Check\Database\Engine.

Class

SiteAuditCheckDatabaseEngine
Class SiteAuditCheckDatabaseEngine.

Code

public function calculateScore() {
  if (version_compare(DRUSH_VERSION, 7, '>=')) {
    $sql = drush_sql_get_class();
    $db_spec = $sql
      ->db_spec();
  }
  else {
    $db_spec = _drush_sql_get_db_spec();
  }
  $sql_query = 'SELECT TABLE_NAME AS name ';
  $sql_query .= ', ENGINE ';
  $sql_query .= 'FROM information_schema.TABLES ';
  $sql_query .= 'WHERE TABLES.table_schema = :dbname ';
  $sql_query .= 'AND ENGINE != :engine ';
  $result = db_query($sql_query, array(
    ':dbname' => $db_spec['database'],
    ':engine' => 'InnoDB',
  ));
  $count = 0;
  foreach ($result as $row) {
    $count++;
    $this->registry['engine_tables'][$row->name] = $row->ENGINE;
  }
  if ($count === 0) {
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
  }
  return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL;
}