28require
'../../main.inc.php';
36$table =
GETPOST(
'table',
'aZ09');
37$field =
GETPOST(
'field',
'aZ09');
38$action =
GETPOST(
'action',
'aZ09');
45if ($action ==
'convertutf8') {
46 $sql =
"SHOW FULL COLUMNS IN ".$db->sanitize($table);
48 $resql = $db->query($sql);
50 $num = $db->num_rows($resql);
53 $row = $db->fetch_row($resql);
54 if ($row[0] == $field) {
55 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" CHARACTER SET utf8";
58 $collation =
'utf8_unicode_ci';
59 $defaultcollation = $db->getDefaultCollationDatabase();
60 if (preg_match(
'/general/', $defaultcollation)) {
61 $collation =
'utf8_general_ci';
64 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" COLLATE ".$db->sanitize($collation);
65 $resql2 = $db->query($sql);
75if ($action ==
'convertutf8mb4') {
76 $sql =
"SHOW FULL COLUMNS IN ".$db->sanitize($table);
78 $resql = $db->query($sql);
80 $num = $db->num_rows($resql);
83 $row = $db->fetch_row($resql);
84 if ($row[0] == $field) {
85 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" CHARACTER SET utf8mb4";
88 $collation =
'utf8mb4_unicode_ci';
89 $defaultcollation = $db->getDefaultCollationDatabase();
90 if (preg_match(
'/general/', $defaultcollation)) {
91 $collation =
'utf8mb4_general_ci';
94 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" COLLATE ".$db->sanitize($collation);
95 $resql2 = $db->query($sql);
111llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-system_dbtable');
114print
load_fiche_titre($langs->trans(
"Table").
" ".$table,
'',
'title_setup');
118if (preg_match(
'/mysql/i', $conf->db->type)) {
119 $sql =
"SHOW TABLE STATUS LIKE '".$db->escape($db->escapeforlike($table)).
"'";
121} elseif ($conf->db->type ==
'pgsql') {
122 $sql =
"SELECT conname,contype FROM pg_constraint";
127 print $langs->trans(
"FeatureNotAvailableWithThisDatabaseDriver");
129 $resql = $db->query($sql);
131 $num = $db->num_rows($resql);
134 $row = $db->fetch_row($resql);
141 $cons = explode(
";", $row[14]);
143 foreach ($cons as $cc) {
144 $cx = preg_replace(
"/\)\sREFER/",
"", $cc);
145 $cx = preg_replace(
"/\(`/",
"", $cx);
146 $cx = preg_replace(
"/`\)/",
"", $cx);
147 $cx = preg_replace(
"/`\s/",
"", $cx);
149 $val = explode(
"`", $cx);
151 $link[trim($val[0])][0] = (isset($val[1]) ? $val[1] :
'');
152 $link[trim($val[0])][1] = (isset($val[2]) ? $val[2] :
'');
156 print
'<div class="div-table-responsive-no-min">';
157 print
'<table class="noborder">';
158 print
'<tr class="liste_titre">';
159 print
'<td>'.$langs->trans(
"Fields").
'</td>';
160 print
'<td>'.$langs->trans(
"Type").
'</td>';
161 print
'<td>'.$langs->trans(
"Collation").
'</td>';
162 print
'<td>'.$langs->trans(
"Null").
'</td>';
163 print
'<td>'.$langs->trans(
"Index").
'</td>';
164 print
'<td>'.$langs->trans(
"Default").
'</td>';
165 print
'<td>'.$langs->trans(
"Extra").
'</td>';
166 print
'<td>'.$langs->trans(
"Privileges").
'</td>';
167 print
'<td>'.$langs->trans(
"FieldsLinked").
'</td>';
171 $sql =
"SHOW FULL COLUMNS IN ".$db->sanitize($table);
173 $resql = $db->query($sql);
175 $num = $db->num_rows($resql);
178 $row = $db->fetch_row($resql);
180 print
'<tr class="oddeven">';
183 print
"<td>".$row[0].
"</td>";
190 if (preg_match(
'/^varchar/', $proptype, $matches)) {
191 $pictoType =
'varchar';
192 } elseif (strpos($proptype,
'int') === 0 || strpos($proptype,
'tinyint') === 0 || strpos($proptype,
'bigint') === 0) {
194 } elseif (strpos($proptype,
'timestamp') === 0) {
195 $pictoType =
'datetime';
196 } elseif (strpos($proptype,
'real') === 0) {
197 $pictoType =
'double';
203 print
"<td>".(empty($row[2]) ?
' ' : $row[2]);
206 if (isset($row[2])) {
207 print
'<br><span class="opacitymedium small">'.$langs->trans(
"ConvertInto");
208 if (!in_array($row[2], array(
"utf8_unicode_ci"))) {
209 print
' <a class="reposition" href="dbtable.php?action=convertutf8&table='.urlencode($table).
'&field='.urlencode($row[0]).
'&token='.
newToken().
'">utf8</a>';
211 if (!in_array($row[2], array(
"utf8mb4_unicode_ci"))) {
212 print
' <a class="reposition" href="dbtable.php?action=convertutf8mb4&table='.urlencode($table).
'&field='.urlencode($row[0]).
'&token='.
newToken().
'">utf8mb4</a>';
222 print
"<td>".$row[3].
"</td>";
224 print
"<td>".(empty($row[4]) ?
'' : $row[4]).
"</td>";
226 print
"<td>".(empty($row[5]) ?
'' : $row[5]).
"</td>";
228 print
"<td>".(empty($row[6]) ?
'' : $row[6]).
"</td>";
230 print
"<td>".(empty($row[7]) ?
'' : $row[7]).
"</td>";
232 print
"<td>".(isset($link[$row[0]][0]) ? $link[$row[0]][0] :
'').
".";
233 print(isset($link[$row[0]][1]) ? $link[$row[0]][1] :
'').
"</td>";
235 print
'<!-- ALTER TABLE '.$table.
' MODIFY '.$row[0].
' '.$row[1].
' COLLATE utf8mb4_unicode_ci; -->';
236 print
'<!-- ALTER TABLE '.$table.
' MODIFY '.$row[0].
' '.$row[1].
' CHARACTER SET utf8mb4; -->';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
getPictoForType($key, $morecss='')
Return the picto for a data type.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.