dolibarr  16.0.5
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 require '../../main.inc.php';
28 
29 $langs->load("admin");
30 
31 if (!$user->admin) {
33 }
34 
35 $table = GETPOST('table', 'alpha');
36 
37 
38 /*
39  * View
40  */
41 
42 llxHeader();
43 
44 
45 print load_fiche_titre($langs->trans("Table")." ".$table, '', 'title_setup');
46 
47 // Define request to get table description
48 $base = 0;
49 if (preg_match('/mysql/i', $conf->db->type)) {
50  $sql = "SHOW TABLE STATUS LIKE '".$db->escape($table)."'";
51  $base = 1;
52 } elseif ($conf->db->type == 'pgsql') {
53  $sql = "SELECT conname,contype FROM pg_constraint";
54  $base = 2;
55 }
56 
57 if (!$base) {
58  print $langs->trans("FeatureNotAvailableWithThisDatabaseDriver");
59 } else {
60  $resql = $db->query($sql);
61  if ($resql) {
62  $num = $db->num_rows($resql);
63  $i = 0;
64  while ($i < $num) {
65  $row = $db->fetch_row($resql);
66  $i++;
67  }
68  }
69 
70  if ($base == 1) { // mysql
71  $link = array();
72  $cons = explode(";", $row[14]);
73  if (!empty($cons)) {
74  foreach ($cons as $cc) {
75  $cx = preg_replace("/\)\sREFER/", "", $cc);
76  $cx = preg_replace("/\(`/", "", $cx);
77  $cx = preg_replace("/`\)/", "", $cx);
78  $cx = preg_replace("/`\s/", "", $cx);
79 
80  $val = explode("`", $cx);
81 
82  $link[trim($val[0])][0] = (isset($val[1]) ? $val[1] : '');
83  $link[trim($val[0])][1] = (isset($val[2]) ? $val[2] : '');
84  }
85  }
86 
87  // var_dump($link);
88 
89  print '<table class="noborder">';
90  print '<tr class="liste_titre">';
91  print '<td>'.$langs->trans("Fields").'</td><td>'.$langs->trans("Type").'</td><td>'.$langs->trans("Index").'</td>';
92  print '<td></td>';
93  print '<td></td>';
94  print '<td></td>';
95  print '<td></td>';
96  print '<td>'.$langs->trans("FieldsLinked").'</td>';
97  print '</tr>';
98 
99  //$sql = "DESCRIBE ".$table;
100  $sql = "SHOW FULL COLUMNS IN ".$db->escape($table);
101 
102  $resql = $db->query($sql);
103  if ($resql) {
104  $num = $db->num_rows($resql);
105  $i = 0;
106  while ($i < $num) {
107  $row = $db->fetch_row($resql);
108  print '<tr class="oddeven">';
109  print "<td>".$row[0]."</td>";
110  print "<td>".$row[1]."</td>";
111  print "<td>".$row[3]."</td>";
112  print "<td>".(empty($row[4]) ? '' : $row[4])."</td>";
113  print "<td>".(empty($row[5]) ? '' : $row[5])."</td>";
114  print "<td>".(empty($row[6]) ? '' : $row[6])."</td>";
115  print "<td>".(empty($row[7]) ? '' : $row[7])."</td>";
116 
117  print "<td>".(isset($link[$row[0]][0]) ? $link[$row[0]][0] : '').".";
118  print (isset($link[$row[0]][1]) ? $link[$row[0]][1] : '')."</td>";
119 
120  print '<!-- ALTER ALTER TABLE '.$table.' MODIFY '.$row[0].' '.$row[1].' COLLATE utf8_unicode_ci; -->';
121  print '</tr>';
122  $i++;
123  }
124  }
125  print '</table>';
126  }
127 }
128 
129 // End of page
130 llxFooter();
131 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59