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 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" COLLATE utf8_unicode_ci";
66if ($action ==
'convertutf8mb4') {
67 $sql =
"SHOW FULL COLUMNS IN ".$db->sanitize($table);
69 $resql = $db->query($sql);
71 $num = $db->num_rows($resql);
74 $row = $db->fetch_row($resql);
75 if ($row[0] == $field) {
76 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" CHARACTER SET utf8mb4";
79 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" COLLATE utf8mb4_unicode_ci";
93llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-system_dbtable');
100if (preg_match(
'/mysql/i', $conf->db->type)) {
101 $sql =
"SHOW TABLE STATUS LIKE '".$db->escape($db->escapeforlike($table)).
"'";
103} elseif ($conf->db->type ==
'pgsql') {
104 $sql =
"SELECT conname,contype FROM pg_constraint";
109 print $langs->trans(
"FeatureNotAvailableWithThisDatabaseDriver");
111 $resql = $db->query($sql);
113 $num = $db->num_rows($resql);
116 $row = $db->fetch_row($resql);
123 $cons = explode(
";", $row[14]);
125 foreach ($cons as $cc) {
126 $cx = preg_replace(
"/\)\sREFER/",
"", $cc);
127 $cx = preg_replace(
"/\(`/",
"", $cx);
128 $cx = preg_replace(
"/`\)/",
"", $cx);
129 $cx = preg_replace(
"/`\s/",
"", $cx);
131 $val = explode(
"`", $cx);
133 $link[trim($val[0])][0] = (isset($val[1]) ? $val[1] :
'');
134 $link[trim($val[0])][1] = (isset($val[2]) ? $val[2] :
'');
138 print
'<table class="noborder">';
139 print
'<tr class="liste_titre">';
140 print
'<td>'.$langs->trans(
"Fields").
'</td>';
141 print
'<td>'.$langs->trans(
"Type").
'</td>';
142 print
'<td>'.$langs->trans(
"Collation").
'</td>';
143 print
'<td>'.$langs->trans(
"Null").
'</td>';
144 print
'<td>'.$langs->trans(
"Index").
'</td>';
145 print
'<td>'.$langs->trans(
"Default").
'</td>';
146 print
'<td>'.$langs->trans(
"Extra").
'</td>';
147 print
'<td>'.$langs->trans(
"Privileges").
'</td>';
148 print
'<td>'.$langs->trans(
"FieldsLinked").
'</td>';
152 $sql =
"SHOW FULL COLUMNS IN ".$db->sanitize($table);
154 $resql = $db->query($sql);
156 $num = $db->num_rows($resql);
159 $row = $db->fetch_row($resql);
161 print
'<tr class="oddeven">';
164 print
"<td>".$row[0].
"</td>";
171 if (preg_match(
'/^varchar/', $proptype, $matches)) {
172 $pictoType =
'varchar';
173 } elseif (strpos($proptype,
'int') === 0 || strpos($proptype,
'tinyint') === 0 || strpos($proptype,
'bigint') === 0) {
175 } elseif (strpos($proptype,
'timestamp') === 0) {
176 $pictoType =
'datetime';
177 } elseif (strpos($proptype,
'real') === 0) {
178 $pictoType =
'double';
184 print
"<td>".(empty($row[2]) ?
' ' : $row[2]);
187 if (isset($row[2])) {
188 print
'<br><span class="opacitymedium small">'.$langs->trans(
"ConvertInto");
189 if (!in_array($row[2], array(
"utf8_unicode_ci"))) {
190 print
' <a class="reposition" href="dbtable.php?action=convertutf8&table='.urlencode($table).
'&field='.urlencode($row[0]).
'&token='.
newToken().
'">utf8</a>';
192 if (!in_array($row[2], array(
"utf8mb4_unicode_ci"))) {
193 print
' <a class="reposition" href="dbtable.php?action=convertutf8mb4&table='.urlencode($table).
'&field='.urlencode($row[0]).
'&token='.
newToken().
'">utf8mb4</a>';
203 print
"<td>".$row[3].
"</td>";
205 print
"<td>".(empty($row[4]) ?
'' : $row[4]).
"</td>";
207 print
"<td>".(empty($row[5]) ?
'' : $row[5]).
"</td>";
209 print
"<td>".(empty($row[6]) ?
'' : $row[6]).
"</td>";
211 print
"<td>".(empty($row[7]) ?
'' : $row[7]).
"</td>";
213 print
"<td>".(isset($link[$row[0]][0]) ? $link[$row[0]][0] :
'').
".";
214 print(isset($link[$row[0]][1]) ? $link[$row[0]][1] :
'').
"</td>";
216 print
'<!-- ALTER TABLE '.$table.
' MODIFY '.$row[0].
' '.$row[1].
' COLLATE utf8_unicode_ci; -->';
217 print
'<!-- ALTER TABLE '.$table.
' MODIFY '.$row[0].
' '.$row[1].
' CHARACTER SET utf8; -->';
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.
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.