30require
'../../main.inc.php';
46$table =
GETPOST(
'table',
'aZ09');
47$field =
GETPOST(
'field',
'aZ09');
48$action =
GETPOST(
'action',
'aZ09');
55if ($action ==
'convertutf8') {
56 $sql =
"SHOW FULL COLUMNS IN ".$db->sanitize($table);
58 $resql = $db->query($sql);
60 $num = $db->num_rows($resql);
63 $row = $db->fetch_row($resql);
64 if ($row[0] == $field) {
65 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" CHARACTER SET utf8";
68 $collation =
'utf8_unicode_ci';
69 $defaultcollation = $db->getDefaultCollationDatabase();
70 if (preg_match(
'/general/', $defaultcollation)) {
71 $collation =
'utf8_general_ci';
74 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" COLLATE ".$db->sanitize($collation);
75 $resql2 = $db->query($sql);
85if ($action ==
'convertutf8mb4') {
86 $sql =
"SHOW FULL COLUMNS IN ".$db->sanitize($table);
88 $resql = $db->query($sql);
90 $num = $db->num_rows($resql);
93 $row = $db->fetch_row($resql);
94 if ($row[0] == $field) {
95 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" CHARACTER SET utf8mb4";
98 $collation =
'utf8mb4_unicode_ci';
99 $defaultcollation = $db->getDefaultCollationDatabase();
100 if (preg_match(
'/general/', $defaultcollation)) {
101 $collation =
'utf8mb4_general_ci';
104 $sql =
"ALTER TABLE ".$db->sanitize($table).
" MODIFY ".$db->sanitize($row[0]).
" ".$row[1].
" COLLATE ".$db->sanitize($collation);
105 $resql2 = $db->query($sql);
121llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-system_dbtable');
124print
load_fiche_titre($langs->trans(
"Table").
" ".$table,
'',
'title_setup');
129if (preg_match(
'/mysql/i',
$conf->db->type)) {
130 $sql =
"SHOW TABLE STATUS LIKE '".$db->escape($db->escapeforlike($table)).
"'";
132} elseif (
$conf->db->type ==
'pgsql') {
133 $sql =
"SELECT conname,contype FROM pg_constraint";
137if (!$base || $sql ===
null) {
138 print $langs->trans(
"FeatureNotAvailableWithThisDatabaseDriver");
140 $resql = $db->query($sql);
142 $num = $db->num_rows($resql);
145 $row = $db->fetch_row($resql);
152 $cons = explode(
";", $row[14]);
154 foreach ($cons as $cc) {
155 $cx = preg_replace(
"/\)\sREFER/",
"", $cc);
156 $cx = preg_replace(
"/\(`/",
"", $cx);
157 $cx = preg_replace(
"/`\)/",
"", $cx);
158 $cx = preg_replace(
"/`\s/",
"", $cx);
160 $val = explode(
"`", $cx);
162 $link[trim($val[0])][0] = (isset($val[1]) ? $val[1] :
'');
163 $link[trim($val[0])][1] = (isset($val[2]) ? $val[2] :
'');
167 print
'<div class="div-table-responsive-no-min">';
168 print
'<table class="noborder">';
169 print
'<tr class="liste_titre">';
170 print
'<td>'.$langs->trans(
"Fields").
'</td>';
171 print
'<td>'.$langs->trans(
"Type").
'</td>';
172 print
'<td>'.$langs->trans(
"Collation").
'</td>';
173 print
'<td>'.$langs->trans(
"Null").
'</td>';
174 print
'<td>'.$langs->trans(
"Index").
'</td>';
175 print
'<td>'.$langs->trans(
"Default").
'</td>';
176 print
'<td>'.$langs->trans(
"Extra").
'</td>';
177 print
'<td>'.$langs->trans(
"Privileges").
'</td>';
178 print
'<td>'.$langs->trans(
"FieldsLinked").
'</td>';
182 $sql =
"SHOW FULL COLUMNS IN ".$db->sanitize($table);
184 $resql = $db->query($sql);
186 $num = $db->num_rows($resql);
189 $row = $db->fetch_row($resql);
191 print
'<tr class="oddeven">';
194 print
"<td>".$row[0].
"</td>";
201 if (preg_match(
'/^varchar/', $proptype, $matches)) {
202 $pictoType =
'varchar';
203 } elseif (strpos($proptype,
'int') === 0 || strpos($proptype,
'tinyint') === 0 || strpos($proptype,
'bigint') === 0) {
205 } elseif (strpos($proptype,
'timestamp') === 0) {
206 $pictoType =
'datetime';
207 } elseif (strpos($proptype,
'real') === 0) {
208 $pictoType =
'double';
214 print
"<td>".(empty($row[2]) ?
' ' : $row[2]);
217 if (isset($row[2])) {
218 print
'<br><span class="opacitymedium small">'.$langs->trans(
"ConvertInto");
219 if (!in_array($row[2], array(
"utf8_unicode_ci"))) {
220 print
' <a class="reposition" href="dbtable.php?action=convertutf8&table='.urlencode($table).
'&field='.urlencode($row[0]).
'&token='.
newToken().
'">utf8</a>';
222 if (!in_array($row[2], array(
"utf8mb4_unicode_ci"))) {
223 print
' <a class="reposition" href="dbtable.php?action=convertutf8mb4&table='.urlencode($table).
'&field='.urlencode($row[0]).
'&token='.
newToken().
'">utf8mb4</a>';
233 print
"<td>".$row[3].
"</td>";
235 print
"<td>".(empty($row[4]) ?
'' : $row[4]).
"</td>";
237 print
"<td>".(empty($row[5]) ?
'' : $row[5]).
"</td>";
239 print
"<td>".(empty($row[6]) ?
'' : $row[6]).
"</td>";
241 print
"<td>".(empty($row[7]) ?
'' : $row[7]).
"</td>";
243 print
"<td>".(isset($link[$row[0]][0]) ? $link[$row[0]][0] :
'').
".";
244 print(isset($link[$row[0]][1]) ? $link[$row[0]][1] :
'').
"</td>";
246 print
'<!-- ALTER TABLE '.$table.
' MODIFY '.$row[0].
' '.$row[1].
' COLLATE utf8mb4_unicode_ci; -->';
247 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...
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.