dolibarr  7.0.0-beta
database-tables.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@capnetworks.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 <http://www.gnu.org/licenses/>.
20  */
21 
27 require '../../main.inc.php';
28 
29 $langs->load("admin");
30 
31 if (! $user->admin)
33 
34 $action=GETPOST('action','alpha');
35 
36 
37 if ($action == 'convert')
38 {
39  $db->query("alter table ".$_GET["table"]." ENGINE=INNODB");
40 }
41 
42 
43 /*
44  * View
45  */
46 
47 llxHeader();
48 
49 print load_fiche_titre($langs->trans("Tables")." ".ucfirst($conf->db->type),'','title_setup');
50 
51 
52 // Define request to get table description
53 $base=0;
54 if (preg_match('/mysql/i',$conf->db->type))
55 {
56  $sql = "SHOW TABLE STATUS";
57  $base=1;
58 }
59 else if ($conf->db->type == 'pgsql')
60 {
61  $sql = "SELECT conname, contype FROM pg_constraint;";
62  $base=2;
63 }
64 else if ($conf->db->type == 'mssql')
65 {
66  //$sqls[0] = "";
67  //$base=3;
68 }
69 else if ($conf->db->type == 'sqlite' || $conf->db->type == 'sqlite3')
70 {
71  //$sql = "SELECT name, type FROM sqlite_master";
72  $base = 4;
73 }
74 
75 
76 if (! $base)
77 {
78  print $langs->trans("FeatureNotAvailableWithThisDatabaseDriver");
79 }
80 else
81 {
82  if ($base == 1)
83  {
84  print '<div class="div-table-responsive-no-min">';
85  print '<table class="noborder">';
86  print '<tr class="liste_titre">';
87  print '<td>'.$langs->trans("TableName").'</td>';
88  print '<td colspan="2">'.$langs->trans("Type").'</td>';
89  print '<td>'.$langs->trans("Format").'</td>';
90  print '<td align="right">'.$langs->trans("NbOfRecord").'</td>';
91  print '<td align="right">Avg_row_length</td>';
92  print '<td align="right">Data_length</td>';
93  print '<td align="right">Max_Data_length</td>';
94  print '<td align="right">Index_length</td>';
95  print '<td align="right">Increment</td>';
96  print '<td align="right">Last check</td>';
97  print '<td align="right">Collation</td>';
98  print "</tr>\n";
99 
100  $sql = "SHOW TABLE STATUS";
101 
102  $resql = $db->query($sql);
103  if ($resql)
104  {
105  $num = $db->num_rows($resql);
106  $i=0;
107  while ($i < $num)
108  {
109  $obj = $db->fetch_object($resql);
110  print '<tr class="oddeven">';
111 
112  print '<td><a href="dbtable.php?table='.$obj->Name.'">'.$obj->Name.'</a></td>';
113  print '<td>'.$obj->Engine.'</td>';
114  if (isset($row[1]) && $row[1] == "MyISAM")
115  {
116  print '<td><a href="database-tables.php?action=convert&amp;table='.$row[0].'">'.$langs->trans("Convert").'</a></td>';
117  }
118  else
119  {
120  print '<td>&nbsp;</td>';
121  }
122  print '<td>'.$obj->Row_format.'</td>';
123  print '<td align="right">'.$obj->Rows.'</td>';
124  print '<td align="right">'.$obj->Avg_row_length.'</td>';
125  print '<td align="right">'.$obj->Data_length.'</td>';
126  print '<td align="right">'.$obj->Max_data_length.'</td>';
127  print '<td align="right">'.$obj->Index_length.'</td>';
128  print '<td align="right">'.$obj->Auto_increment.'</td>';
129  print '<td align="right">'.$obj->Check_time.'</td>';
130  print '<td align="right">'.$obj->Collation.'</td>';
131  print '</tr>';
132  $i++;
133  }
134  }
135  print '</table>';
136  print '</div>';
137  }
138 
139  if ($base == 2)
140  {
141  print '<div class="div-table-responsive-no-min">';
142  print '<table class="noborder">';
143  print '<tr class="liste_titre">';
144  print '<td>'.$langs->trans("TableName").'</td>';
145  print '<td>Nb of tuples</td>';
146  print '<td>Nb index fetcher.</td>';
147  print '<td>Nb tuples insert</td>';
148  print '<td>Nb tuples modify</td>';
149  print '<td>Nb tuples delete</td>';
150  print "</tr>\n";
151 
152  $sql = "SELECT relname, seq_tup_read, idx_tup_fetch, n_tup_ins, n_tup_upd, n_tup_del";
153  $sql.= " FROM pg_stat_user_tables";
154 
155  $resql = $db->query($sql);
156  if ($resql)
157  {
158  $num = $db->num_rows($resql);
159  $i=0;
160  while ($i < $num)
161  {
162  $row = $db->fetch_row($resql);
163  print '<tr class="oddeven">';
164  print '<td>'.$row[0].'</td>';
165  print '<td align="right">'.$row[1].'</td>';
166  print '<td align="right">'.$row[2].'</td>';
167  print '<td align="right">'.$row[3].'</td>';
168  print '<td align="right">'.$row[4].'</td>';
169  print '<td align="right">'.$row[5].'</td>';
170  print '</tr>';
171  $i++;
172  }
173  }
174  print '</table>';
175  print '</div>';
176  }
177 
178  if ($base == 4)
179  {
180  // Sqlite by PDO or by Sqlite3
181  print '<div class="div-table-responsive-no-min">';
182  print '<table class="noborder">';
183  print '<tr class="liste_titre">';
184  print '<td>'.$langs->trans("TableName").'</td>';
185  print '<td>'.$langs->trans("NbOfRecord").'</td>';
186  print "</tr>\n";
187 
188  $sql = "SELECT name, type FROM sqlite_master where type='table' and name not like 'sqlite%' ORDER BY name";
189  $resql = $db->query($sql);
190 
191  if ($resql)
192  {
193  while ($row = $db->fetch_row($resql)) {
194 
195  $rescount = $db->query("SELECT COUNT(*) FROM " . $row[0]);
196  if ($rescount) {
197  $row_count = $db->fetch_row($rescount);
198  $count = $row_count[0];
199  } else {
200  $count = '?';
201  }
202 
203  print '<tr class="oddeven">';
204  print '<td>'.$row[0].'</td>';
205  print '<td>'.$count.'</td>';
206  print '</tr>';
207  }
208  }
209 
210  print '</table>';
211  print '</div>';
212  }
213 }
214 
215 llxFooter();
216 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
GETPOST($paramname, $check='none', $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)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013