public function SiteAuditCheckDatabaseRowCount::calculateScore in Site Audit 8.2
Same name and namespace in other branches
- 7 Check/Database/RowCount.php \SiteAuditCheckDatabaseRowCount::calculateScore()
Implements \SiteAudit\Check\Abstract\calculateScore().
Overrides SiteAuditCheckAbstract::calculateScore
File
- Check/
Database/ RowCount.php, line 95 - Contains \SiteAudit\Check\Database\RowCount.
Class
- SiteAuditCheckDatabaseRowCount
- Class SiteAuditCheckDatabaseRowCount.
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();
}
$this->registry['rows_by_table'] = array();
$warning = FALSE;
$sql_query = 'SELECT TABLE_NAME AS table_name, TABLE_ROWS AS table_rows ';
$sql_query .= 'FROM information_schema.TABLES ';
$sql_query .= 'WHERE TABLES.TABLE_SCHEMA = :dbname ';
$sql_query .= 'AND TABLE_ROWS >= :count ';
$sql_query .= 'ORDER BY TABLE_ROWS desc ';
$result = db_query($sql_query, array(
':count' => drush_get_option('min_rows', SiteAuditCheckDatabaseRowCount::AUDIT_CHECK_DB_ROW_MIN_DEFAULT),
':dbname' => $db_spec['database'],
));
foreach ($result as $row) {
if ($row->rows > drush_get_option('min_rows', SiteAuditCheckDatabaseRowCount::AUDIT_CHECK_DB_ROW_MIN_DEFAULT)) {
$warning = TRUE;
}
$this->registry['rows_by_table'][$row->table_name] = $row->rows;
}
if ($warning) {
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
}
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
}