-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdb_admin.php
More file actions
104 lines (90 loc) · 3.03 KB
/
db_admin.php
File metadata and controls
104 lines (90 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
use phpGrid\C_DataGrid;
require_once("phpGridx/conf.php");
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DB Admin</title>
</head>
<body>
<style type='text/css'>
.wrapper{
width: 100%;
margin: 0 auto;
}
.header{
float: left;
width: 100%;
text-align: center;
}
.wrapright{
float: left;
width: 100%;
}
.right{
margin-left: 310px;
height: 200px;
}
.left{
float: left;
width: 300px;
margin-left: -100%;
height: 200px;
}
body {
padding: 15px;
margin: 15px;
}
</style>
<div class="wrapper">
<div class="header">
<h1>Database Table Data CRUD Admin Console</h1>
</div>
<div class="wrapright">
<div class="right">
<?php
$schemaName = (isset($_GET['TABLE_SCHEMA']) && isset($_GET['TABLE_SCHEMA']) !== '') ? $_GET['TABLE_SCHEMA'] : 'sampledb';
$tableName = (isset($_GET['TABLE_NAME']) && isset($_GET['TABLE_NAME']) !== '') ? $_GET['TABLE_NAME'] : 'orders';
//$dg = new C_DataGrid("SELECT * FROM $schemaName.$tableName");
$dg = new C_DataGrid("SELECT * FROM $tableName",'orderNumber', "$tableName",
array("hostname"=>"localhost",
"username"=>"root",
"password"=>"",
"dbname"=>$schemaName,
"dbtype"=>"mysql",
"dbcharset"=>"utf8"));
$dg->set_caption(strtoupper("$schemaName.$tableName"));
$dg->enable_autowidth(true);
$dg->enable_edit();
$dg->set_scroll(true);
$dg->enable_global_search(true);
// uncomment to set width to parent DIV instead
$dg->before_script_end .= 'setTimeout(function(){$(window).bind("resize", function() {
phpGrid_'. $tableName .'.setGridWidth($(".right").width());
}).trigger("resize");}, 0)';
$dg -> display();
?>
</div>
</div>
<div class="left">
<?php
// schema list
$dbs = new C_DataGrid("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA", "SCHEMA_NAME", "INFORMATION_SCHEMA.SCHEMATA");
$dbs->set_dimension('300px');
$dbs->set_pagesize(999)->set_scroll(true);
// table list
$tbl = new C_DataGrid("SELECT TABLE_NAME, TABLE_SCHEMA, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES", "TABLE_NAME", "INFORMATION_SCHEMA.TABLES");
$tbl->set_col_hidden('TABLE_SCHEMA');
$tbl->set_pagesize(999)->set_scroll(true);
$tbl -> set_col_dynalink("TABLE_NAME", "db_admin.php", array("TABLE_NAME", "TABLE_SCHEMA"), '', "_top");
//$tbl->set_col_title('TABLE_NAME', 'Name')->set_col_title('TABLE_ROWS', 'Count');
$dbs->set_subgrid($tbl, 'TABLE_SCHEMA', 'SCHEMA_NAME');
$dbs->display();
?>
</div>
</div>
TODO: add form only mode
</body>
</html>