27if (! defined(
'CSRFCHECK_WITH_TOKEN')) {
28 define(
'CSRFCHECK_WITH_TOKEN',
'1');
32require
'../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
42$action =
GETPOST(
'action',
'aZ09');
49if ($action ==
'convert') {
50 $sql =
"ALTER TABLE ".$db->escape(
GETPOST(
"table",
"aZ09")).
" ENGINE=INNODB";
53if ($action ==
'convertutf8') {
54 $sql =
"ALTER TABLE ".$db->escape(
GETPOST(
"table",
"aZ09")).
" CHARACTER SET utf8 COLLATE utf8_unicode_ci";
57if ($action ==
'convertdynamic') {
58 $sql =
"ALTER TABLE ".$db->escape(
GETPOST(
"table",
"aZ09")).
" ROW_FORMAT=DYNAMIC;";
69print
load_fiche_titre($langs->trans(
"Tables").
" ".ucfirst($conf->db->type),
'',
'title_setup');
74if (preg_match(
'/mysql/i', $conf->db->type)) {
75 $sql =
"SHOW TABLE STATUS";
77} elseif ($conf->db->type ==
'pgsql') {
78 $sql =
"SELECT conname, contype FROM pg_constraint;";
80} elseif ($conf->db->type ==
'mssql') {
83} elseif ($conf->db->type ==
'sqlite' || $conf->db->type ==
'sqlite3') {
90 print $langs->trans(
"FeatureNotAvailableWithThisDatabaseDriver");
93 print
'<div class="div-table-responsive-no-min">';
94 print
'<table class="noborder">';
95 print
'<tr class="liste_titre">';
97 print
'<td>'.$langs->trans(
"TableName").
'</td>';
98 print
'<td colspan="2">'.$langs->trans(
"Type").
'</td>';
99 print
'<td>'.$langs->trans(
"Format").
'</td>';
100 print
'<td class="right">'.$langs->trans(
"NbOfRecord").
'</td>';
101 print
'<td class="right">Avg_row_length</td>';
102 print
'<td class="right">Data_length</td>';
103 print
'<td class="right">Max_Data_length</td>';
104 print
'<td class="right">Index_length</td>';
105 print
'<td class="right">Increment</td>';
106 print
'<td class="right">Last check</td>';
107 print
'<td class="right">Collation</td>';
110 $arrayoffilesrich =
dol_dir_list(DOL_DOCUMENT_ROOT.
'/install/mysql/tables/',
'files', 0,
'\.sql$');
111 $arrayoffiles = array();
112 $arrayoftablesautocreated = array();
113 foreach ($arrayoffilesrich as $value) {
115 $shortsqlfilename = preg_replace(
'/\-[a-z]+\./',
'.', $value[
'name']);
116 $arrayoffiles[$value[
'name']] = $shortsqlfilename;
117 if ($value[
'name'] == $shortsqlfilename && ! preg_match(
'/\.key\.sql$/', $value[
'name'])) {
119 $arrayoftablesautocreated[$value[
'name']] = $shortsqlfilename;
124 $sql =
"SHOW TABLE STATUS";
126 $resql = $db->query($sql);
128 $num = $db->num_rows($resql);
131 $obj = $db->fetch_object($resql);
133 print
'<tr class="oddeven">';
135 print
'<td>'.($i+1).
'</td>';
136 print
'<td><a href="dbtable.php?table='.$obj->Name.
'">'.$obj->Name.
'</a>';
137 $tablename = preg_replace(
'/^'.MAIN_DB_PREFIX.
'/',
'llx_', $obj->Name);
139 if (in_array($tablename.
'.sql', $arrayoffiles)) {
140 if (in_array($tablename.
'.sql', $arrayoftablesautocreated)) {
144 print
img_picto($langs->trans(
"NotAvailableByDefaultEnabledOnModuleActivation"), $img,
'class="small opacitymedium"');
148 print
img_picto($langs->trans(
"ExternalModule"), $img,
'class="small"');
151 print
'<td>'.$obj->Engine.
'</td>';
152 if (isset($obj->Engine) && $obj->Engine ==
"MyISAM") {
153 print
'<td><a class="reposition" href="database-tables.php?action=convert&table='.urlencode($obj->Name).
'&token='.newToken().
'">'.$langs->trans(
"Convert").
' InnoDb</a></td>';
155 print
'<td> </td>';
158 print $obj->Row_format;
159 if (isset($obj->Row_format) && (in_array($obj->Row_format, array(
"Compact")))) {
160 print
'<br><a class="reposition" href="database-tables.php?action=convertdynamic&table='.urlencode($obj->Name).
'&token='.newToken().
'">'.$langs->trans(
"Convert").
' Dynamic</a>';
163 print
'<td align="right">'.$obj->Rows.
'</td>';
164 print
'<td align="right">'.$obj->Avg_row_length.
'</td>';
165 print
'<td align="right">'.$obj->Data_length.
'</td>';
166 print
'<td align="right">'.$obj->Max_data_length.
'</td>';
167 print
'<td align="right">'.$obj->Index_length.
'</td>';
168 print
'<td align="right">'.$obj->Auto_increment.
'</td>';
169 print
'<td align="right">'.$obj->Check_time.
'</td>';
170 print
'<td align="right">'.$obj->Collation;
171 if (isset($obj->Collation) && (in_array($obj->Collation, array(
"utf8mb4_general_ci",
"utf8mb4_unicode_ci",
"latin1_swedish_ci")))) {
172 print
'<br><a class="reposition" href="database-tables.php?action=convertutf8&table='.urlencode($obj->Name).
'&token='.newToken().
'">'.$langs->trans(
"Convert").
' UTF8</a>';
184 print
'<div class="div-table-responsive-no-min">';
185 print
'<table class="noborder">';
186 print
'<tr class="liste_titre">';
189 print
'<td>'.$langs->trans(
"TableName").
'</td>';
190 print
'<td>Nb of tuples</td>';
191 print
'<td>Nb index fetcher.</td>';
192 print
'<td>Nb tuples insert</td>';
193 print
'<td>Nb tuples modify</td>';
194 print
'<td>Nb tuples delete</td>';
197 $sql =
"SELECT relname, seq_tup_read, idx_tup_fetch, n_tup_ins, n_tup_upd, n_tup_del";
198 $sql .=
" FROM pg_stat_user_tables";
200 $resql = $db->query($sql);
202 $num = $db->num_rows($resql);
205 $row = $db->fetch_row($resql);
206 print
'<tr class="oddeven">';
207 print
'<td>'.($i+1).
'</td>';
208 print
'<td>'.$row[0].
'</td>';
209 print
'<td class="right">'.$row[1].
'</td>';
210 print
'<td class="right">'.$row[2].
'</td>';
211 print
'<td class="right">'.$row[3].
'</td>';
212 print
'<td class="right">'.$row[4].
'</td>';
213 print
'<td class="right">'.$row[5].
'</td>';
224 print
'<div class="div-table-responsive-no-min">';
225 print
'<table class="noborder">';
226 print
'<tr class="liste_titre">';
228 print
'<td>'.$langs->trans(
"TableName").
'</td>';
229 print
'<td>'.$langs->trans(
"NbOfRecord").
'</td>';
232 $sql =
"SELECT name, type FROM sqlite_master where type='table' and name not like 'sqlite%' ORDER BY name";
233 $resql = $db->query($sql);
236 while ($row = $db->fetch_row($resql)) {
237 $rescount = $db->query(
"SELECT COUNT(*) FROM ".$row[0]);
239 $row_count = $db->fetch_row($rescount);
240 $count = $row_count[0];
245 print
'<tr class="oddeven">';
246 print
'<td>'.($i+1).
'</td>';
247 print
'<td>'.$row[0].
'</td>';
248 print
'<td>'.$count.
'</td>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.