public function filter_optimize_database($result, $paramarray) { $space_saved = 0; $tables = 0; switch (DB::get_driver_name()) { case 'mysql': $q = 'SHOW TABLE STATUS WHERE data_free > 0'; $tables = DB::get_results($q); if (count($tables) > 0) { foreach ($tables as $table) { $q2 = 'OPTIMIZE TABLE ' . $table->Name; if (DB::query($q2)) { $space_saved += $table->Data_free; $tables++; } } EventLog::log('Database Tables Optimized. ' . Utils::human_size($space_saved) . ' reclaimed from ' . HabariLocale::_n('table', 'tables', $tables) . '.'); } $result = true; break; case 'sqlite': if (DB::exec('VACUUM')) { $result = true; EventLog::log('SQLite database VACUUM\'ed successfully.'); } else { $result = false; } break; default: $result = false; break; } return $result; }
/** * Return a singular or plural string translated into the current locale based on the count provided * * @param string $singular The singular form * @param string $plural The plural form * @param string $count The count * @return string The appropriately translated string **/ function _n($singular, $plural, $count, $domain = 'habari') { return HabariLocale::_n($singular, $plural, $count, $domain); }