PluginProbe
Optimize Database after Deleting Revisions / 4.0.1
Optimize Database after Deleting Revisions v4.0.1
3.4.7 3.4.8 3.4.9 3.5 3.5.1 4.0 4.0.1 4.0.2 4.0.3 4.1 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.3 All 144 releases
rvg-optimize-database / classes / odb-utilities.php

odb-utilities.php in Optimize Database after Deleting Revisions 4.0.1, at classes/odb-utilities.php

71 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /************************************************************************************************
3 *
4 * UTILITIES
5 *
6 ************************************************************************************************/
7 ?>
8 <?php
9 class ODB_Utilities
10 {
11 /********************************************************************************************
12 * CONSTRUCTOR
13 ********************************************************************************************/
14 function __construct()
15 {
16 } // __construct()
17
18
19 /********************************************************************************************
20 * FORMAT SIZES FROM BYTES TO KB OR MB
21 ********************************************************************************************/
22 function odb_format_size($size, $precision=1)
23 {
24 if($size>1024*1024)
25 $table_size = (round($size/(1024*1024),$precision)).' MB';
26 else
27 $table_size = (round($size/1024,$precision)).' KB';
28
29 return $table_size;
30 } // odb_format_size()
31
32
33 /********************************************************************************************
34 * CALCULATE THE SIZE OF THE WORDPRESS DATABASE (IN BYTES)
35 ********************************************************************************************/
36 function odb_get_db_size()
37 {
38 global $wpdb;
39
40 $sql = "
41 SELECT SUM(data_length + index_length) AS size
42 FROM information_schema.TABLES
43 WHERE table_schema = '".DB_NAME."'
44 GROUP BY table_schema
45 ";
46
47 $res = $wpdb->get_results($sql);
48
49 return $res[0]->size;
50 } // odb_get_db_size()
51
52
53 /********************************************************************************************
54 * GET DATABASE TABLES
55 ********************************************************************************************/
56 function odb_get_tables()
57 {
58 global $wpdb;
59
60 $sql = "
61 SHOW FULL TABLES
62 FROM `".DB_NAME."`
63 WHERE table_type = 'BASE TABLE'
64 ";
65
66 // GET THE DATABASE BASE TABLES
67 // $odb_class->odb_tables = $wpdb->get_results($sql, ARRAY_N);
68 // var_dump($wpdb->get_results($sql, ARRAY_N));
69 return $wpdb->get_results($sql, ARRAY_N);
70 } // odb_get_tables()
71 } // ODB_Utilities