function test_database_utf8() { if (!db_is_mysql()) { return; } // table collation/character set check $result = db_query_bound('SHOW TABLE STATUS'); while ($row = db_fetch_array($result)) { if ($row['Comment'] !== 'VIEW') { print_test_row('Checking Table Collation is utf8 for ' . $row['Name'] . '....', substr($row['Collation'], 0, 5) === 'utf8_', $row['Collation']); } } foreach (db_get_table_list() as $t_table) { if (db_table_exists($t_table)) { $result = db_query_bound('SHOW FULL FIELDS FROM ' . $t_table); while ($row = db_fetch_array($result)) { if ($row['Collation'] === null) { continue; } print_test_row('Checking Non-null Column Collation in ' . $t_table . ' is utf8 for ' . $row['Field'] . '....', substr($row['Collation'], 0, 5) === 'utf8_', $row['Collation'] . ' ( ' . $row['Type'] . ')'); } } } }
/** * Check if the specified table exists. * @param string $p_table_name a valid database table name * @return bool indicating whether the table exists */ function db_table_exists($p_table_name) { if (is_blank($p_table_name)) { return false; } $t_tables = db_get_table_list(); # Can't use in_array() since it is case sensitive $t_table_name = utf8_strtolower($p_table_name); foreach ($t_tables as $t_current_table) { if (utf8_strtolower($t_current_table) == $t_table_name) { return true; } } return false; }
* @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net * @link http://www.mantisbt.org */ /** * MantisBT Core API's */ require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'core.php'; access_ensure_global_level(config_get_global('admin_site_threshold')); # -------------------- function helper_table_row_count($p_table) { $t_table = $p_table; $query = "SELECT COUNT(*) FROM {$t_table}"; $result = db_query_bound($query); $t_users = db_result($result); return $t_users; } # -------------------- function print_table_stats($p_table_name) { $t_count = helper_table_row_count($p_table_name); echo "{$p_table_name} = {$t_count} records<br />"; } echo '<html><head><title>MantisBT Database Statistics</title></head><body>'; echo '<h1>MantisBT Database Statistics</h1>'; foreach (db_get_table_list() as $t_table) { if (db_table_exists($t_table)) { print_table_stats($t_table); } } echo '</body></html>';
function sys_refresh_tablelist() { global $sn_cache; $sn_cache->tables = db_get_table_list(); }