1 | <?php |
||
14 | class Database extends BaseEventEmitter implements DatabaseInterface |
||
15 | { |
||
16 | use LoopAwareTrait; |
||
17 | |||
18 | /** |
||
19 | * @var int |
||
20 | */ |
||
21 | const STATE_INIT = 0; |
||
22 | |||
23 | /** |
||
24 | * @var int |
||
25 | */ |
||
26 | const STATE_CONNECT_PENDING = 4; |
||
27 | |||
28 | /** |
||
29 | * @var int |
||
30 | */ |
||
31 | const STATE_CONNECT_FAILED = 2; |
||
32 | |||
33 | /** |
||
34 | * @var int |
||
35 | */ |
||
36 | const STATE_CONNECT_SUCCEEDED = 6; |
||
37 | |||
38 | /** |
||
39 | * @var int |
||
40 | */ |
||
41 | const STATE_AUTH_PENDING = 5; |
||
42 | |||
43 | /** |
||
44 | * @var int |
||
45 | */ |
||
46 | const STATE_AUTH_FAILED = 3; |
||
47 | |||
48 | /** |
||
49 | * @var int |
||
50 | */ |
||
51 | const STATE_AUTH_SUCCEEDED = 7; |
||
52 | |||
53 | /** |
||
54 | * @var int |
||
55 | */ |
||
56 | const STATE_DISCONNECT_PENDING = 8; |
||
57 | |||
58 | /** |
||
59 | * @var int |
||
60 | */ |
||
61 | const STATE_DISCONNECT_SUCCEEDED = 1; |
||
62 | |||
63 | /** |
||
64 | * @var mixed[] |
||
65 | */ |
||
66 | protected $config; |
||
67 | |||
68 | /** |
||
69 | * @var mixed[] |
||
70 | */ |
||
71 | protected $serverInfo; |
||
72 | |||
73 | /** |
||
74 | * @var int |
||
75 | */ |
||
76 | protected $state; |
||
77 | |||
78 | /** |
||
79 | * @var |
||
80 | */ |
||
81 | protected $queue; |
||
82 | |||
83 | /** |
||
84 | * @var TransactionBoxInterface |
||
85 | */ |
||
86 | protected $transBox; |
||
87 | |||
88 | /** |
||
89 | * @param LoopInterface $loop |
||
90 | * @param mixed[] $config |
||
91 | */ |
||
92 | public function __construct(LoopInterface $loop, $config = []) |
||
100 | |||
101 | /** |
||
102 | * @override |
||
103 | * @inheritDoc |
||
104 | */ |
||
105 | public function isPaused() |
||
110 | |||
111 | /** |
||
112 | * @override |
||
113 | * @inheritDoc |
||
114 | */ |
||
115 | public function pause() |
||
119 | |||
120 | /** |
||
121 | * @override |
||
122 | * @inheritDoc |
||
123 | */ |
||
124 | public function resume() |
||
128 | |||
129 | /** |
||
130 | * @override |
||
131 | * @inheritDoc |
||
132 | */ |
||
133 | public function isStarted() |
||
137 | |||
138 | /** |
||
139 | * @override |
||
140 | * @inheritDoc |
||
141 | */ |
||
142 | public function start() |
||
151 | |||
152 | /** |
||
153 | * @override |
||
154 | * @inheritDoc |
||
155 | */ |
||
156 | public function stop() |
||
165 | |||
166 | /** |
||
167 | * @override |
||
168 | * @inheritDoc |
||
169 | */ |
||
170 | public function getState() |
||
174 | |||
175 | /** |
||
176 | * @override |
||
177 | * @inheritDoc |
||
178 | */ |
||
179 | public function getInfo() |
||
183 | |||
184 | /** |
||
185 | * @override |
||
186 | * @inheritDoc |
||
187 | */ |
||
188 | public function setDatabase($dbname) |
||
193 | |||
194 | /** |
||
195 | * @override |
||
196 | * @inheritDoc |
||
197 | */ |
||
198 | public function getDatabase() |
||
202 | |||
203 | /** |
||
204 | * @override |
||
205 | * @inheritDoc |
||
206 | */ |
||
207 | public function query($sql, $sqlParams = []) |
||
212 | |||
213 | /** |
||
214 | * @override |
||
215 | * @inheritDoc |
||
216 | */ |
||
217 | public function execute($sql, $sqlParams = []) |
||
224 | |||
225 | /** |
||
226 | * @override |
||
227 | * @inheritDoc |
||
228 | */ |
||
229 | public function ping() |
||
234 | |||
235 | /** |
||
236 | * @override |
||
237 | * @inheritDoc |
||
238 | */ |
||
239 | public function beginTransaction() |
||
260 | |||
261 | /** |
||
262 | * @override |
||
263 | * @inheritDoc |
||
264 | */ |
||
265 | public function endTransaction(TransactionInterface $trans) |
||
269 | |||
270 | /** |
||
271 | * Try to commit a transaction. |
||
272 | * |
||
273 | * @param mixed[] $queue |
||
274 | * @return PromiseInterface |
||
275 | */ |
||
276 | protected function commitTransaction($queue) |
||
281 | |||
282 | /** |
||
283 | * @override |
||
284 | * @inheritDoc |
||
285 | */ |
||
286 | public function inTransaction() |
||
290 | |||
291 | /** |
||
292 | * Create transaction box. |
||
293 | * |
||
294 | * @return TransactionBoxInterface |
||
295 | */ |
||
296 | protected function createTransactionBox() |
||
300 | |||
301 | /** |
||
302 | * Create configuration file. |
||
303 | * |
||
304 | * @param mixed[] $config |
||
305 | * @return mixed[] |
||
306 | */ |
||
307 | protected function createConfig($config = []) |
||
317 | } |
||
318 |