30require
'../../main.inc.php';
38$table =
GETPOST(
'table',
'aZ09');
39$field =
GETPOST(
'field',
'aZ09');
40$action =
GETPOST(
'action',
'aZ09');
47if ($action ==
'convertutf8') {
48 $sql =
"SHOW FULL COLUMNS IN ".$db->sanitize($table);
50 $resql = $db->query($sql);
52 $num = $db->num_rows($resql);
55 $row = $db->fetch_row($resql);
56 if ($row[0] == $field) {
57 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" CHARACTER SET utf8";
60 $collation =
'utf8_unicode_ci';
61 $defaultcollation = $db->getDefaultCollationDatabase();
62 if (preg_match(
'/general/', $defaultcollation)) {
63 $collation =
'utf8_general_ci';
66 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" COLLATE ".$db->sanitize($collation);
67 $resql2 = $db->query($sql);
77if ($action ==
'convertutf8mb4') {
78 $sql =
"SHOW FULL COLUMNS IN ".$db->sanitize($table);
80 $resql = $db->query($sql);
82 $num = $db->num_rows($resql);
85 $row = $db->fetch_row($resql);
86 if ($row[0] == $field) {
87 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" CHARACTER SET utf8mb4";
90 $collation =
'utf8mb4_unicode_ci';
91 $defaultcollation = $db->getDefaultCollationDatabase();
92 if (preg_match(
'/general/', $defaultcollation)) {
93 $collation =
'utf8mb4_general_ci';
96 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" COLLATE ".$db->sanitize($collation);
97 $resql2 = $db->query($sql);
113llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-system_dbtable');
116print
load_fiche_titre($langs->trans(
"Table").
" ".$table,
'',
'title_setup');
121if (preg_match(
'/mysql/i', $conf->db->type)) {
122 $sql =
"SHOW TABLE STATUS LIKE '".$db->escape($db->escapeforlike($table)).
"'";
124} elseif ($conf->db->type ==
'pgsql') {
125 $sql =
"SELECT conname,contype FROM pg_constraint";
129if (!$base || $sql ===
null) {
130 print $langs->trans(
"FeatureNotAvailableWithThisDatabaseDriver");
132 $resql = $db->query($sql);
134 $num = $db->num_rows($resql);
137 $row = $db->fetch_row($resql);
144 $cons = explode(
";", $row[14]);
146 foreach ($cons as $cc) {
147 $cx = preg_replace(
"/\)\sREFER/",
"", $cc);
148 $cx = preg_replace(
"/\(`/",
"", $cx);
149 $cx = preg_replace(
"/`\)/",
"", $cx);
150 $cx = preg_replace(
"/`\s/",
"", $cx);
152 $val = explode(
"`", $cx);
154 $link[trim($val[0])][0] = (isset($val[1]) ? $val[1] :
'');
155 $link[trim($val[0])][1] = (isset($val[2]) ? $val[2] :
'');
159 print
'<div class="div-table-responsive-no-min">';
160 print
'<table class="noborder">';
161 print
'<tr class="liste_titre">';
162 print
'<td>'.$langs->trans(
"Fields").
'</td>';
163 print
'<td>'.$langs->trans(
"Type").
'</td>';
164 print
'<td>'.$langs->trans(
"Collation").
'</td>';
165 print
'<td>'.$langs->trans(
"Null").
'</td>';
166 print
'<td>'.$langs->trans(
"Index").
'</td>';
167 print
'<td>'.$langs->trans(
"Default").
'</td>';
168 print
'<td>'.$langs->trans(
"Extra").
'</td>';
169 print
'<td>'.$langs->trans(
"Privileges").
'</td>';
170 print
'<td>'.$langs->trans(
"FieldsLinked").
'</td>';
174 $sql =
"SHOW FULL COLUMNS IN ".$db->sanitize($table);
176 $resql = $db->query($sql);
178 $num = $db->num_rows($resql);
181 $row = $db->fetch_row($resql);
183 print
'<tr class="oddeven">';
186 print
"<td>".$row[0].
"</td>";
193 if (preg_match(
'/^varchar/', $proptype, $matches)) {
194 $pictoType =
'varchar';
195 } elseif (strpos($proptype,
'int') === 0 || strpos($proptype,
'tinyint') === 0 || strpos($proptype,
'bigint') === 0) {
197 } elseif (strpos($proptype,
'timestamp') === 0) {
198 $pictoType =
'datetime';
199 } elseif (strpos($proptype,
'real') === 0) {
200 $pictoType =
'double';
206 print
"<td>".(empty($row[2]) ?
' ' : $row[2]);
209 if (isset($row[2])) {
210 print
'<br><span class="opacitymedium small">'.$langs->trans(
"ConvertInto");
211 if (!in_array($row[2], array(
"utf8_unicode_ci"))) {
212 print
' <a class="reposition" href="dbtable.php?action=convertutf8&table='.urlencode($table).
'&field='.urlencode($row[0]).
'&token='.
newToken().
'">utf8</a>';
214 if (!in_array($row[2], array(
"utf8mb4_unicode_ci"))) {
215 print
' <a class="reposition" href="dbtable.php?action=convertutf8mb4&table='.urlencode($table).
'&field='.urlencode($row[0]).
'&token='.
newToken().
'">utf8mb4</a>';
225 print
"<td>".$row[3].
"</td>";
227 print
"<td>".(empty($row[4]) ?
'' : $row[4]).
"</td>";
229 print
"<td>".(empty($row[5]) ?
'' : $row[5]).
"</td>";
231 print
"<td>".(empty($row[6]) ?
'' : $row[6]).
"</td>";
233 print
"<td>".(empty($row[7]) ?
'' : $row[7]).
"</td>";
235 print
"<td>".(isset($link[$row[0]][0]) ? $link[$row[0]][0] :
'').
".";
236 print(isset($link[$row[0]][1]) ? $link[$row[0]][1] :
'').
"</td>";
238 print
'<!-- ALTER TABLE '.$table.
' MODIFY '.$row[0].
' '.$row[1].
' COLLATE utf8mb4_unicode_ci; -->';
239 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
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.
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.
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.