dolibarr  19.0.0-dev
dbtable.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
5  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
6  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
27 // Load Dolibarr environment
28 require '../../main.inc.php';
29 
30 $langs->load("admin");
31 
32 if (!$user->admin) {
34 }
35 
36 $table = GETPOST('table', 'alpha');
37 
38 
39 /*
40  * View
41  */
42 
43 llxHeader();
44 
45 
46 print load_fiche_titre($langs->trans("Table")." ".$table, '', 'title_setup');
47 
48 // Define request to get table description
49 $base = 0;
50 if (preg_match('/mysql/i', $conf->db->type)) {
51  $sql = "SHOW TABLE STATUS LIKE '".$db->escape($table)."'";
52  $base = 1;
53 } elseif ($conf->db->type == 'pgsql') {
54  $sql = "SELECT conname,contype FROM pg_constraint";
55  $base = 2;
56 }
57 
58 if (!$base) {
59  print $langs->trans("FeatureNotAvailableWithThisDatabaseDriver");
60 } else {
61  $resql = $db->query($sql);
62  if ($resql) {
63  $num = $db->num_rows($resql);
64  $i = 0;
65  while ($i < $num) {
66  $row = $db->fetch_row($resql);
67  $i++;
68  }
69  }
70 
71  if ($base == 1) { // mysql
72  $link = array();
73  $cons = explode(";", $row[14]);
74  if (!empty($cons)) {
75  foreach ($cons as $cc) {
76  $cx = preg_replace("/\‍)\sREFER/", "", $cc);
77  $cx = preg_replace("/\‍(`/", "", $cx);
78  $cx = preg_replace("/`\‍)/", "", $cx);
79  $cx = preg_replace("/`\s/", "", $cx);
80 
81  $val = explode("`", $cx);
82 
83  $link[trim($val[0])][0] = (isset($val[1]) ? $val[1] : '');
84  $link[trim($val[0])][1] = (isset($val[2]) ? $val[2] : '');
85  }
86  }
87 
88  // var_dump($link);
89 
90  print '<table class="noborder">';
91  print '<tr class="liste_titre">';
92  print '<td>'.$langs->trans("Fields").'</td><td>'.$langs->trans("Type").'</td><td>'.$langs->trans("Index").'</td>';
93  print '<td></td>';
94  print '<td></td>';
95  print '<td></td>';
96  print '<td></td>';
97  print '<td>'.$langs->trans("FieldsLinked").'</td>';
98  print '</tr>';
99 
100  //$sql = "DESCRIBE ".$table;
101  $sql = "SHOW FULL COLUMNS IN ".$db->escape($table);
102 
103  $resql = $db->query($sql);
104  if ($resql) {
105  $num = $db->num_rows($resql);
106  $i = 0;
107  while ($i < $num) {
108  $row = $db->fetch_row($resql);
109  print '<tr class="oddeven">';
110  print "<td>".$row[0]."</td>";
111  print "<td>".$row[1]."</td>";
112  print "<td>".$row[3]."</td>";
113  print "<td>".(empty($row[4]) ? '' : $row[4])."</td>";
114  print "<td>".(empty($row[5]) ? '' : $row[5])."</td>";
115  print "<td>".(empty($row[6]) ? '' : $row[6])."</td>";
116  print "<td>".(empty($row[7]) ? '' : $row[7])."</td>";
117 
118  print "<td>".(isset($link[$row[0]][0]) ? $link[$row[0]][0] : '').".";
119  print (isset($link[$row[0]][1]) ? $link[$row[0]][1] : '')."</td>";
120 
121  print '<!-- ALTER ALTER TABLE '.$table.' MODIFY '.$row[0].' '.$row[1].' COLLATE utf8_unicode_ci; -->';
122  print '</tr>';
123  $i++;
124  }
125  }
126  print '</table>';
127  }
128 }
129 
130 // End of page
131 llxFooter();
132 $db->close();
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.