<?php
include_once("c_debug_info.php");
include_once(_DIR_TO_MODULES.'/engine/i_disk.php') ;
class c_page_cab_debug_info_db extends c_page_cab_debug_info
{
  public $h1='Информация по БД' ;


  function block_main()
  { $this->page_title() ;
    $this->panel_info() ;
  }

    function panel_info()
    {  ?><h2>Информация по таблицам БД</h2><?
       $recs_table=execSQL('
       SELECT TABLE_NAME,TABLE_TYPE,ENGINE,TABLE_COLLATION, AUTO_INCREMENT, data_length, index_length, (data_length + index_length) "size",table_rows 
       FROM information_schema.TABLES 
       WHERE table_schema = "'.$GLOBALS['_SETTING']['main_db']['db_name'].'"
       order by TABLE_NAME
       ');

       ?><table class="basic fz_small  auto"><th>Название таблицы</th><th>Тип</th><th>engine</th><th>Сопоставление</th><th>Счетчик</th><th>Размер данных</th><th>Размер индекса</th><th>Размер таблицы</th><th>Число строк</th><?
       foreach($recs_table as $rec)
       { ?><tr>
             <td class="left"><a href="/window/db/table/[table_name=<?echo $rec['TABLE_NAME']?>]/" class="new_window" target="_blank"><?echo $rec['TABLE_NAME']?></a></td>
             <td class="left"><?echo $rec['TABLE_TYPE']?></td>
             <td class="left"><?echo $rec['ENGINE']?></td>
             <td class="left"><?echo $rec['TABLE_COLLATION']?></td>
             <td class="right"><?echo $rec['AUTO_INCREMENT']?></td>
             <td class="right"><?if ($rec['data_length']) echo show_size($rec['data_length'])?></td>
             <td class="right"><?if ($rec['index_length']) echo show_size($rec['index_length'])?></td>
             <td class="right"><?if ($rec['size']) echo show_size($rec['size'])?></td>
             <td class="right"><?if ($rec['table_rows']) echo number_format($rec['table_rows'],0,"."," ")?></td>
          </tr><?
        }
        ?></table><br><?
       ?><button class="button v2" cmd="db/delete_temp_tables">Удалить временнные таблицы</button>&nbsp;&nbsp;<?
       ?><button class="button v2" cmd="db/delete_view_personals">Удалить вьюверы сотрудников таблицы</button><?
    }


}



?>