29if (! defined(
'CSRFCHECK_WITH_TOKEN')) {
30 define(
'CSRFCHECK_WITH_TOKEN',
'1');
34require
'../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
52$table =
GETPOST(
'table',
'aZ09');
53$action =
GETPOST(
'action',
'aZ09');
60if ($action ==
'convert') {
61 $sql =
"ALTER TABLE ".$db->sanitize($table).
" ENGINE=INNODB";
64if ($action ==
'convertutf8') {
65 $collation =
'utf8_unicode_ci';
66 $defaultcollation = $db->getDefaultCollationDatabase();
67 if (preg_match(
'/general/', $defaultcollation)) {
68 $collation =
'utf8_general_ci';
70 $sql =
"ALTER TABLE ".$db->sanitize($table).
" CHARACTER SET utf8 COLLATE ".$db->sanitize($collation);
71 $resql1 = $db->query($sql);
75 $sql =
"ALTER TABLE ".$db->sanitize($table).
" CONVERT TO CHARACTER SET utf8 COLLATE ".$db->sanitize($collation);
76 $resql2 = $db->query($sql);
82if ($action ==
'convertutf8mb4') {
83 $collation =
'utf8mb4_unicode_ci';
84 $defaultcollation = $db->getDefaultCollationDatabase();
85 if (preg_match(
'/general/', $defaultcollation)) {
86 $collation =
'utf8mb4_general_ci';
88 $sql =
"ALTER TABLE ".$db->sanitize($table).
" CHARACTER SET utf8mb4 COLLATE ".$db->sanitize($collation);
89 $resql1 = $db->query($sql);
93 $sql =
"ALTER TABLE ".$db->sanitize($table).
" CONVERT TO CHARACTER SET utf8mb4 COLLATE ".$db->sanitize($collation);
94 $resql2 = $db->query($sql);
100if ($action ==
'convertdynamic') {
101 $sql =
"ALTER TABLE ".$db->sanitize($table).
" ROW_FORMAT=DYNAMIC;";
110llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-database_tables');
117if (preg_match(
'/mysql/i',
$conf->db->type)) {
118 $sql =
"SHOW TABLE STATUS";
120} elseif (
$conf->db->type ==
'pgsql') {
121 $sql =
"SELECT conname, contype FROM pg_constraint;";
123} elseif (
$conf->db->type ==
'mssql') {
126} elseif (
$conf->db->type ==
'sqlite' ||
$conf->db->type ==
'sqlite3') {
133 print $langs->trans(
"FeatureNotAvailableWithThisDatabaseDriver");
137 print
'<div class="div-table-responsive-no-min">';
138 print
'<table class="noborder">';
139 print
'<tr class="liste_titre">';
141 print
'<td>'.$langs->trans(
"TableName").
'</td>';
142 print
'<td colspan="2">'.$langs->trans(
"Type").
'</td>';
143 print
'<td>'.$langs->trans(
"Format").
'</td>';
144 print
'<td class="right">'.$langs->trans(
"NbOfRecord").
'</td>';
145 print
'<td class="right">Avg_row_length</td>';
146 print
'<td class="right">Data_length</td>';
147 print
'<td class="right">Max_Data_length</td>';
148 print
'<td class="right">Index_length</td>';
149 print
'<td class="right">Increment</td>';
150 print
'<td class="right">Last check</td>';
151 print
'<td class="right">Collation</td>';
154 $arrayoffilesrich =
dol_dir_list(DOL_DOCUMENT_ROOT.
'/install/mysql/tables/',
'files', 0,
'\.sql$');
155 $arrayoffiles = array();
156 $arrayoftablesautocreated = array();
157 foreach ($arrayoffilesrich as $value) {
159 $shortsqlfilename = preg_replace(
'/\-[a-z]+\./',
'.', $value[
'name']);
160 $arrayoffiles[$value[
'name']] = $shortsqlfilename;
161 if ($value[
'name'] == $shortsqlfilename && ! preg_match(
'/\.key\.sql$/', $value[
'name'])) {
163 $arrayoftablesautocreated[$value[
'name']] = $shortsqlfilename;
168 $sql =
"SHOW TABLE STATUS";
170 $resql = $db->query($sql);
172 $num = $db->num_rows($resql);
175 $obj = $db->fetch_object($resql);
177 print
'<tr class="oddeven">';
179 print
'<td>'.($i + 1).
'</td>';
180 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($obj->Name).
'"><a href="dbtable.php?table='.urlencode($obj->Name).
'">'.$obj->Name.
'</a>';
181 $tablename = preg_replace(
'/^'.MAIN_DB_PREFIX.
'/',
'llx_', $obj->Name);
183 if (in_array($tablename.
'.sql', $arrayoffiles)) {
184 if (in_array($tablename.
'.sql', $arrayoftablesautocreated)) {
188 print
img_picto($langs->trans(
"NotAvailableByDefaultEnabledOnModuleActivation"), $img,
'class="small opacitymedium"');
192 print
img_picto($langs->trans(
"ExternalModule"), $img,
'class="small"');
195 print
'<td>'.$obj->Engine.
'</td>';
196 if (isset($obj->Engine) && $obj->Engine ==
"MyISAM") {
197 print
'<td><a class="reposition" href="database-tables.php?action=convert&table='.urlencode($obj->Name).
'&token='.
newToken().
'">'.$langs->trans(
"Convert").
' InnoDb</a></td>';
199 print
'<td> </td>';
202 print $obj->Row_format;
203 if (isset($obj->Row_format) && (in_array($obj->Row_format, array(
"Compact")))) {
204 print
'<br><a class="reposition" href="database-tables.php?action=convertdynamic&table='.urlencode($obj->Name).
'&token='.
newToken().
'">'.$langs->trans(
"Convert").
' Dynamic</a>';
207 print
'<td class="right">'.$obj->Rows.
'</td>';
208 print
'<td class="right">'.$obj->Avg_row_length.
'</td>';
209 print
'<td class="right">'.$obj->Data_length.
'</td>';
210 print
'<td class="right">'.$obj->Max_data_length.
'</td>';
211 print
'<td class="right">'.$obj->Index_length.
'</td>';
212 print
'<td class="right">'.$obj->Auto_increment.
'</td>';
213 print
'<td class="right">'.$obj->Check_time.
'</td>';
214 print
'<td class="right nowraponall">'.$obj->Collation;
216 if (isset($obj->Collation)) {
217 print
'<br><span class="opacitymedium small">'.$langs->trans(
"ConvertInto");
218 if (!in_array($obj->Collation, array(
"utf8_unicode_ci"))) {
219 print
' <a class="reposition" href="database-tables.php?action=convertutf8&table='.urlencode($obj->Name).
'&token='.
newToken().
'">utf8</a>';
221 if (!in_array($obj->Collation, array(
"utf8mb4_unicode_ci"))) {
222 print
' <a class="reposition" href="database-tables.php?action=convertutf8mb4&table='.urlencode($obj->Name).
'&token='.
newToken().
'">utf8mb4</a>';
236 print
'<div class="div-table-responsive-no-min">';
237 print
'<table class="noborder">';
238 print
'<tr class="liste_titre">';
241 print
'<td>'.$langs->trans(
"TableName").
'</td>';
242 print
'<td>Nb of tuples</td>';
243 print
'<td>Nb index fetcher.</td>';
244 print
'<td>Nb tuples insert</td>';
245 print
'<td>Nb tuples modify</td>';
246 print
'<td>Nb tuples delete</td>';
249 $sql =
"SELECT relname, seq_tup_read, idx_tup_fetch, n_tup_ins, n_tup_upd, n_tup_del";
250 $sql .=
" FROM pg_stat_user_tables ORDER BY relname";
252 $resql = $db->query($sql);
254 $num = $db->num_rows($resql);
257 $row = $db->fetch_row($resql);
258 print
'<tr class="oddeven">';
259 print
'<td>'.($i + 1).
'</td>';
260 print
'<td>'.$row[0].
'</td>';
261 print
'<td class="right">'.$row[1].
'</td>';
262 print
'<td class="right">'.$row[2].
'</td>';
263 print
'<td class="right">'.$row[3].
'</td>';
264 print
'<td class="right">'.$row[4].
'</td>';
265 print
'<td class="right">'.$row[5].
'</td>';
276 print
'<div class="div-table-responsive-no-min">';
277 print
'<table class="noborder">';
278 print
'<tr class="liste_titre">';
280 print
'<td>'.$langs->trans(
"TableName").
'</td>';
281 print
'<td>'.$langs->trans(
"NbOfRecord").
'</td>';
284 $sql =
"SELECT name, type FROM sqlite_master where type='table' and name not like 'sqlite%' ORDER BY name";
285 $resql = $db->query($sql);
288 while ($row = $db->fetch_row($resql)) {
289 $rescount = $db->query(
"SELECT COUNT(*) FROM ".$row[0]);
291 $row_count = $db->fetch_row($rescount);
292 $count = $row_count[0];
297 print
'<tr class="oddeven">';
298 print
'<td>'.($i + 1).
'</td>';
299 print
'<td>'.$row[0].
'</td>';
300 print
'<td>'.$count.
'</td>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
dol_dir_list($utf8_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($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.