Example #1
0
/**
 * returns array with tables of given db with extended information and grouped
 *
 * @param string   $db           name of db
 * @param string   $tables       name of tables
 * @param integer  $limit_offset list offset
 * @param int|bool $limit_count  max tables to return
 *
 * @return  array    (recursive) grouped table list
 */
function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count = false)
{
    $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
    if (null === $tables) {
        $tables = PMA_DBI_get_tables_full($db, false, false, null, $limit_offset, $limit_count);
        if ($GLOBALS['cfg']['NaturalOrder']) {
            uksort($tables, 'strnatcasecmp');
        }
    }
    if (count($tables) < 1) {
        return $tables;
    }
    $default = array('Name' => '', 'Rows' => 0, 'Comment' => '', 'disp_name' => '');
    $table_groups = array();
    // for blobstreaming - list of blobstreaming tables
    // load PMA configuration
    $PMA_Config = $GLOBALS['PMA_Config'];
    foreach ($tables as $table_name => $table) {
        // if BS tables exist
        if (PMA_BS_IsHiddenTable($table_name)) {
            continue;
        }
        // check for correct row count
        if (null === $table['Rows']) {
            // Do not check exact row count here,
            // if row count is invalid possibly the table is defect
            // and this would break left frame;
            // but we can check row count if this is a view or the
            // information_schema database
            // since PMA_Table::countRecords() returns a limited row count
            // in this case.
            // set this because PMA_Table::countRecords() can use it
            $tbl_is_view = $table['TABLE_TYPE'] == 'VIEW';
            if ($tbl_is_view || PMA_is_system_schema($db)) {
                $table['Rows'] = PMA_Table::countRecords($db, $table['Name'], false, true);
            }
        }
        // in $group we save the reference to the place in $table_groups
        // where to store the table info
        if ($GLOBALS['cfg']['LeftFrameDBTree'] && $sep && strstr($table_name, $sep)) {
            $parts = explode($sep, $table_name);
            $group =& $table_groups;
            $i = 0;
            $group_name_full = '';
            $parts_cnt = count($parts) - 1;
            while ($i < $parts_cnt && $i < $GLOBALS['cfg']['LeftFrameTableLevel']) {
                $group_name = $parts[$i] . $sep;
                $group_name_full .= $group_name;
                if (!isset($group[$group_name])) {
                    $group[$group_name] = array();
                    $group[$group_name]['is' . $sep . 'group'] = true;
                    $group[$group_name]['tab' . $sep . 'count'] = 1;
                    $group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
                } elseif (!isset($group[$group_name]['is' . $sep . 'group'])) {
                    $table = $group[$group_name];
                    $group[$group_name] = array();
                    $group[$group_name][$group_name] = $table;
                    unset($table);
                    $group[$group_name]['is' . $sep . 'group'] = true;
                    $group[$group_name]['tab' . $sep . 'count'] = 1;
                    $group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
                } else {
                    $group[$group_name]['tab' . $sep . 'count']++;
                }
                $group =& $group[$group_name];
                $i++;
            }
        } else {
            if (!isset($table_groups[$table_name])) {
                $table_groups[$table_name] = array();
            }
            $group =& $table_groups;
        }
        if ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested' && $table['Comment'] && $table['Comment'] != 'VIEW') {
            // switch tooltip and name
            $table['disp_name'] = $table['Comment'];
            $table['Comment'] = $table['Name'];
        } else {
            $table['disp_name'] = $table['Name'];
        }
        $group[$table_name] = array_merge($default, $table);
    }
    return $table_groups;
}
Example #2
0
/**
 * returns count of tables in given db
 *
 * @param string  $db database to count tables for
 * @return  integer count of tables in $db
 */
function PMA_getTableCount($db)
{
    $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
    if ($tables) {
        $num_tables = PMA_DBI_num_rows($tables);
        // do not count hidden blobstreaming tables
        while ($num_tables > 0 && ($data = PMA_DBI_fetch_assoc($tables))) {
            if (PMA_BS_IsHiddenTable($data['Tables_in_' . $db])) {
                $num_tables--;
            }
        }
        PMA_DBI_free_result($tables);
    } else {
        $num_tables = 0;
    }
    return $num_tables;
}
Example #3
0
echo PMA_generate_common_hidden_inputs($db);
PMA_TableHeader($db_is_information_schema, $server_slave_status);
$i = $sum_entries = 0;
$sum_size = (double) 0;
$overhead_size = (double) 0;
$overhead_check = '';
$checked = !empty($checkall) ? ' checked="checked"' : '';
$num_columns = $cfg['PropertiesNumColumns'] > 1 ? ceil($num_tables / $cfg['PropertiesNumColumns']) + 1 : 0;
$row_count = 0;
$hidden_fields = array();
$odd_row = true;
$sum_row_count_pre = '';
$tableReductionCount = 0;
// the amount to reduce the table count by
foreach ($tables as $keyname => $each_table) {
    if (PMA_BS_IsHiddenTable($keyname)) {
        $tableReductionCount++;
        continue;
    }
    // Get valid statistics whatever is the table type
    $table_is_view = false;
    $table_encoded = urlencode($each_table['TABLE_NAME']);
    // Sets parameters for links
    $tbl_url_query = $url_query . '&amp;table=' . $table_encoded;
    // do not list the previous table's size info for a view
    $formatted_size = '-';
    $unit = '';
    switch ($each_table['ENGINE']) {
        // MyISAM, ISAM or Heap table: Row count, data size and index size
        // are accurate; data size is accurate for ARCHIVE
        case 'MyISAM':
Example #4
0
/**
 * returns count of tables in given db
 *
 * @uses    PMA_DBI_try_query()
 * @uses    PMA_backquote()
 * @uses    PMA_DBI_QUERY_STORE()
 * @uses    PMA_DBI_num_rows()
 * @uses    PMA_DBI_free_result()
 * @param   string  $db database to count tables for
 * @return  integer count of tables in $db
 */
function PMA_getTableCount($db)
{
    $tables = PMA_DBI_try_query("SELECT TABLE_NAME FROM ALL_TABLES WHERE OWNER LIKE '" . $db . "'", null, PMA_DBI_QUERY_STORE);
    if ($tables) {
        $num_tables = PMA_DBI_num_rows($tables);
        // do not count hidden blobstreaming tables
        while ($num_tables > 0 && ($data = PMA_DBI_fetch_assoc($tables))) {
            if (PMA_BS_IsHiddenTable($data['Tables_in_' . $db])) {
                $num_tables--;
            }
        }
        PMA_DBI_free_result($tables);
    } else {
        $num_tables = 0;
    }
    return $num_tables;
}