1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Lagdo\DbAdmin\Driver; |
4
|
|
|
|
5
|
|
|
use Lagdo\DbAdmin\Driver\Entity\UserEntity; |
6
|
|
|
|
7
|
|
|
trait ServerTrait |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Get the users and hosts |
11
|
|
|
* |
12
|
|
|
* @param string $database The database name |
13
|
|
|
* |
14
|
|
|
* @return array |
15
|
|
|
*/ |
16
|
|
|
public function getUsers(string $database): array |
17
|
|
|
{ |
18
|
|
|
return $this->server->getUsers($database); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Get the grants of a user on a given host |
23
|
|
|
* |
24
|
|
|
* @param string $user The username |
25
|
|
|
* @param string $host The host name |
26
|
|
|
* |
27
|
|
|
* @return UserEntity |
28
|
|
|
*/ |
29
|
|
|
public function getUserGrants(string $user, string $host): UserEntity |
30
|
|
|
{ |
31
|
|
|
return $this->server->getUserGrants($user, $host); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Get the user privileges |
36
|
|
|
* |
37
|
|
|
* @param UserEntity $user |
38
|
|
|
* |
39
|
|
|
* @return void |
40
|
|
|
*/ |
41
|
|
|
public function getUserPrivileges(UserEntity $user) |
42
|
|
|
{ |
43
|
|
|
$this->server->getUserPrivileges($user); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Get cached list of databases |
48
|
|
|
* |
49
|
|
|
* @param bool $flush |
50
|
|
|
* |
51
|
|
|
* @return array |
52
|
|
|
*/ |
53
|
|
|
public function databases(bool $flush) |
54
|
|
|
{ |
55
|
|
|
return $this->server->databases($flush); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Compute size of database |
60
|
|
|
* |
61
|
|
|
* @param string $database |
62
|
|
|
* |
63
|
|
|
* @return int |
64
|
|
|
*/ |
65
|
|
|
public function databaseSize(string $database) |
66
|
|
|
{ |
67
|
|
|
return $this->server->databaseSize($database); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Get database collation |
72
|
|
|
* |
73
|
|
|
* @param string $database |
74
|
|
|
* @param array $collations |
75
|
|
|
* |
76
|
|
|
* @return string |
77
|
|
|
*/ |
78
|
|
|
public function databaseCollation(string $database, array $collations) |
79
|
|
|
{ |
80
|
|
|
return $this->server->databaseCollation($database, $collations); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Get supported engines |
85
|
|
|
* |
86
|
|
|
* @return array |
87
|
|
|
*/ |
88
|
|
|
public function engines() |
89
|
|
|
{ |
90
|
|
|
return $this->server->engines(); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Get sorted grouped list of collations |
95
|
|
|
* |
96
|
|
|
* @return array |
97
|
|
|
*/ |
98
|
|
|
public function collations() |
99
|
|
|
{ |
100
|
|
|
return $this->server->collations(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Find out if database is information_schema |
105
|
|
|
* |
106
|
|
|
* @param string $database |
107
|
|
|
* |
108
|
|
|
* @return bool |
109
|
|
|
*/ |
110
|
|
|
public function isInformationSchema(string $database) |
111
|
|
|
{ |
112
|
|
|
return $this->server->isInformationSchema($database); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Create a database |
117
|
|
|
* |
118
|
|
|
* @param string $database |
119
|
|
|
* @param string $collation |
120
|
|
|
* |
121
|
|
|
* @return string|boolean |
122
|
|
|
*/ |
123
|
|
|
public function createDatabase(string $database, string $collation) |
124
|
|
|
{ |
125
|
|
|
return $this->server->createDatabase($database, $collation); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Drop a database |
130
|
|
|
* |
131
|
|
|
* @param string $database |
132
|
|
|
* |
133
|
|
|
* @return bool |
134
|
|
|
*/ |
135
|
|
|
public function dropDatabase(string $database) |
136
|
|
|
{ |
137
|
|
|
return $this->server->dropDatabase($database); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Rename database from DB |
142
|
|
|
* |
143
|
|
|
* @param string $name New name |
144
|
|
|
* @param string $collation |
145
|
|
|
* |
146
|
|
|
* @return bool |
147
|
|
|
*/ |
148
|
|
|
public function renameDatabase(string $name, string $collation) |
149
|
|
|
{ |
150
|
|
|
return $this->server->renameDatabase($name, $collation); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Get list of available routine languages |
155
|
|
|
* |
156
|
|
|
* @return array |
157
|
|
|
*/ |
158
|
|
|
public function routineLanguages() |
159
|
|
|
{ |
160
|
|
|
return $this->server->routineLanguages(); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Get routine signature |
165
|
|
|
* |
166
|
|
|
* @param string $name |
167
|
|
|
* @param array $row result of routine() |
168
|
|
|
* |
169
|
|
|
* @return string |
170
|
|
|
*/ |
171
|
|
|
public function routineId(string $name, array $row) |
172
|
|
|
{ |
173
|
|
|
return $this->server->routineId($name, $row); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* Get server variables |
178
|
|
|
* |
179
|
|
|
* @return array |
180
|
|
|
*/ |
181
|
|
|
public function variables() |
182
|
|
|
{ |
183
|
|
|
return $this->server->variables(); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Get status variables |
188
|
|
|
* |
189
|
|
|
* @return array |
190
|
|
|
*/ |
191
|
|
|
public function statusVariables() |
192
|
|
|
{ |
193
|
|
|
return $this->server->statusVariables(); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* Get process list |
198
|
|
|
* |
199
|
|
|
* @return array |
200
|
|
|
*/ |
201
|
|
|
public function processes() |
202
|
|
|
{ |
203
|
|
|
return $this->server->processes(); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* Get a process name |
208
|
|
|
* |
209
|
|
|
* @param array $process |
210
|
|
|
* @param string $key |
211
|
|
|
* @param string $val |
212
|
|
|
* |
213
|
|
|
* @return string |
214
|
|
|
*/ |
215
|
|
|
public function processAttr(array $process, string $key, string $val): string |
216
|
|
|
{ |
217
|
|
|
return $this->server->processAttr($process, $key, $val); |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* Kill a process |
222
|
|
|
* |
223
|
|
|
* @param int |
224
|
|
|
* |
225
|
|
|
* @return bool |
226
|
|
|
*/ |
227
|
|
|
// public function killProcess($val) |
228
|
|
|
// { |
229
|
|
|
// return $this->server->killProcess($val); |
230
|
|
|
// } |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* Get maximum number of connections |
234
|
|
|
* |
235
|
|
|
* @return int |
236
|
|
|
*/ |
237
|
|
|
// public function maxConnections() |
238
|
|
|
// { |
239
|
|
|
// return $this->server->maxConnections(); |
240
|
|
|
// } |
241
|
|
|
} |
242
|
|
|
|