1 | <?php |
||
29 | class Database extends BaseEventEmitter implements DatabaseInterface |
||
30 | { |
||
31 | use LoopAwareTrait; |
||
32 | |||
33 | /** |
||
34 | * @var int |
||
35 | */ |
||
36 | const STATE_INIT = 0; |
||
37 | |||
38 | /** |
||
39 | * @var int |
||
40 | */ |
||
41 | const STATE_CONNECT_PENDING = 4; |
||
42 | |||
43 | /** |
||
44 | * @var int |
||
45 | */ |
||
46 | const STATE_CONNECT_FAILED = 2; |
||
47 | |||
48 | /** |
||
49 | * @var int |
||
50 | */ |
||
51 | const STATE_CONNECT_SUCCEEDED = 6; |
||
52 | |||
53 | /** |
||
54 | * @var int |
||
55 | */ |
||
56 | const STATE_AUTH_PENDING = 5; |
||
57 | |||
58 | /** |
||
59 | * @var int |
||
60 | */ |
||
61 | const STATE_AUTH_FAILED = 3; |
||
62 | |||
63 | /** |
||
64 | * @var int |
||
65 | */ |
||
66 | const STATE_AUTH_SUCCEEDED = 7; |
||
67 | |||
68 | /** |
||
69 | * @var int |
||
70 | */ |
||
71 | const STATE_DISCONNECT_PENDING = 8; |
||
72 | |||
73 | /** |
||
74 | * @var int |
||
75 | */ |
||
76 | const STATE_DISCONNECT_SUCCEEDED = 1; |
||
77 | |||
78 | /** |
||
79 | * @var mixed[] |
||
80 | */ |
||
81 | protected $config; |
||
82 | |||
83 | /** |
||
84 | * @var mixed[] |
||
85 | */ |
||
86 | protected $serverInfo; |
||
87 | |||
88 | /** |
||
89 | * @var int |
||
90 | */ |
||
91 | protected $state; |
||
92 | |||
93 | /** |
||
94 | * @var Queue|QueueInterface |
||
95 | */ |
||
96 | protected $queue; |
||
97 | |||
98 | /** |
||
99 | * @var ProtocolParser|null |
||
100 | */ |
||
101 | protected $parser; |
||
102 | |||
103 | /** |
||
104 | * @var SocketInterface|null |
||
105 | */ |
||
106 | protected $stream; |
||
107 | |||
108 | /** |
||
109 | * @var TransactionBoxInterface |
||
110 | */ |
||
111 | protected $transBox; |
||
112 | |||
113 | /** |
||
114 | * @param LoopInterface $loop |
||
115 | * @param mixed[] $config |
||
116 | */ |
||
117 | public function __construct(LoopInterface $loop, $config = []) |
||
128 | |||
129 | /** |
||
130 | * @override |
||
131 | * @inheritDoc |
||
132 | */ |
||
133 | public function isPaused() |
||
138 | |||
139 | /** |
||
140 | * @override |
||
141 | * @inheritDoc |
||
142 | */ |
||
143 | public function pause() |
||
147 | |||
148 | /** |
||
149 | * @override |
||
150 | * @inheritDoc |
||
151 | */ |
||
152 | public function resume() |
||
156 | |||
157 | /** |
||
158 | * @override |
||
159 | * @inheritDoc |
||
160 | */ |
||
161 | public function isStarted() |
||
165 | |||
166 | /** |
||
167 | * @override |
||
168 | * @inheritDoc |
||
169 | */ |
||
170 | public function start() |
||
214 | |||
215 | /** |
||
216 | * @override |
||
217 | * @inheritDoc |
||
218 | */ |
||
219 | public function stop() |
||
236 | |||
237 | /** |
||
238 | * @override |
||
239 | * @inheritDoc |
||
240 | */ |
||
241 | public function getState() |
||
245 | |||
246 | /** |
||
247 | * @override |
||
248 | * @inheritDoc |
||
249 | */ |
||
250 | public function getInfo() |
||
254 | |||
255 | /** |
||
256 | * @override |
||
257 | * @inheritDoc |
||
258 | */ |
||
259 | public function setDatabase($dbname) |
||
263 | |||
264 | /** |
||
265 | * @override |
||
266 | * @inheritDoc |
||
267 | */ |
||
268 | public function getDatabase() |
||
272 | |||
273 | /** |
||
274 | * @override |
||
275 | * @inheritDoc |
||
276 | */ |
||
277 | public function query($sql, $sqlParams = []) |
||
294 | |||
295 | /** |
||
296 | * @override |
||
297 | * @inheritDoc |
||
298 | */ |
||
299 | public function execute($sql, $sqlParams = []) |
||
305 | |||
306 | /** |
||
307 | * @override |
||
308 | * @inheritDoc |
||
309 | */ |
||
310 | public function ping() |
||
324 | |||
325 | /** |
||
326 | * @override |
||
327 | * @inheritDoc |
||
328 | */ |
||
329 | public function beginTransaction() |
||
350 | |||
351 | /** |
||
352 | * @override |
||
353 | * @inheritDoc |
||
354 | */ |
||
355 | public function endTransaction(TransactionInterface $trans) |
||
359 | |||
360 | /** |
||
361 | * Try to commit a transaction. |
||
362 | * |
||
363 | * @param SplQueue $queue |
||
364 | * @return PromiseInterface |
||
365 | */ |
||
366 | protected function commitTransaction(SplQueue $queue) |
||
404 | |||
405 | /** |
||
406 | * @override |
||
407 | * @inheritDoc |
||
408 | */ |
||
409 | public function inTransaction() |
||
413 | |||
414 | /** |
||
415 | * @internal |
||
416 | */ |
||
417 | public function handleError($err) |
||
421 | |||
422 | /** |
||
423 | * @internal |
||
424 | */ |
||
425 | public function handleSocketError($socket, $err) |
||
429 | |||
430 | /** |
||
431 | * @internal |
||
432 | */ |
||
433 | public function handleSocketClose() |
||
441 | |||
442 | /** |
||
443 | * Do auth command. |
||
444 | * |
||
445 | * @param CommandInterface $command |
||
446 | * @return CommandInterface |
||
447 | * @throws ExecutionException |
||
448 | */ |
||
449 | protected function doAuth(CommandInterface $command) |
||
457 | |||
458 | /** |
||
459 | * Do command. |
||
460 | * |
||
461 | * @param CommandInterface $command |
||
462 | * @return CommandInterface |
||
463 | * @throws ExecutionException |
||
464 | */ |
||
465 | protected function doCommand($command) |
||
473 | |||
474 | /** |
||
475 | * Connect to the database endpoint. |
||
476 | * |
||
477 | * @return PromiseInterface |
||
478 | */ |
||
479 | protected function connect() |
||
485 | |||
486 | /** |
||
487 | * Create Queue. |
||
488 | * |
||
489 | * @return Queue|QueueInterface |
||
490 | */ |
||
491 | protected function createQueue() |
||
495 | |||
496 | /** |
||
497 | * Create transaction box. |
||
498 | * |
||
499 | * @return TransactionBoxInterface |
||
500 | */ |
||
501 | protected function createTransactionBox() |
||
505 | |||
506 | /** |
||
507 | * Create configuration file. |
||
508 | * |
||
509 | * @param mixed[] $config |
||
510 | * @return mixed[] |
||
511 | */ |
||
512 | protected function createConfig($config = []) |
||
522 | } |
||
523 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.