1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Plasma Driver MySQL component |
4
|
|
|
* Copyright 2018-2019 PlasmaPHP, All Rights Reserved |
5
|
|
|
* |
6
|
|
|
* Website: https://github.com/PlasmaPHP |
7
|
|
|
* License: https://github.com/PlasmaPHP/driver-mysql/blob/master/LICENSE |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Plasma\Drivers\MySQL\Messages; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Represents an EOF Message. |
14
|
|
|
*/ |
15
|
|
|
class EOFMessage implements \Plasma\Drivers\MySQL\Messages\MessageInterface { |
16
|
|
|
/** |
17
|
|
|
* The server status flags. |
18
|
|
|
* @var int |
19
|
|
|
* @see \Plasma\Drivers\MySQL\StatusFlags |
20
|
|
|
*/ |
21
|
|
|
public $statusFlags; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Count of warnings. |
25
|
|
|
* @var int |
26
|
|
|
*/ |
27
|
|
|
public $warningsCount; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var \Plasma\Drivers\MySQL\ProtocolParser |
31
|
|
|
* @internal |
32
|
|
|
*/ |
33
|
|
|
protected $parser; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Constructor. |
37
|
|
|
* @param \Plasma\Drivers\MySQL\ProtocolParser $parser |
38
|
|
|
* @internal |
39
|
|
|
*/ |
40
|
|
|
function __construct(\Plasma\Drivers\MySQL\ProtocolParser $parser) { |
41
|
|
|
$this->parser = $parser; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Get the identifier for the packet. |
46
|
|
|
* @return string |
47
|
|
|
* @internal |
48
|
|
|
*/ |
49
|
49 |
|
static function getID(): string { |
50
|
49 |
|
return "\xFE"; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Parses the message, once the complete string has been received. |
55
|
|
|
* Returns false if not enough data has been received, or the remaining buffer. |
56
|
|
|
* @param \Plasma\BinaryBuffer $buffer |
57
|
|
|
* @return bool |
58
|
|
|
* @throws \Plasma\Drivers\MySQL\Messages\ParseException |
59
|
|
|
* @internal |
60
|
|
|
*/ |
61
|
|
|
function parseMessage(\Plasma\BinaryBuffer $buffer): bool { |
62
|
|
|
$handshake = $this->parser->getHandshakeMessage(); |
63
|
|
|
if(!$handshake) { |
64
|
|
|
throw new \Plasma\Drivers\MySQL\Messages\ParseException('No handshake message when receiving ok response packet'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
$this->statusFlags = $buffer->readInt2(); |
68
|
|
|
$this->warningsCount = $buffer->readInt2(); |
69
|
|
|
|
70
|
|
|
return true; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Get the parser which created this message. |
75
|
|
|
* @return \Plasma\Drivers\MySQL\ProtocolParser |
76
|
|
|
* @internal |
77
|
|
|
*/ |
78
|
|
|
function getParser(): \Plasma\Drivers\MySQL\ProtocolParser { |
79
|
|
|
return $this->parser; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Sets the parser state, if necessary. If not, return `-1`. |
84
|
|
|
* @return int |
85
|
|
|
* @internal |
86
|
|
|
*/ |
87
|
|
|
function setParserState(): int { |
88
|
|
|
return \Plasma\Drivers\MySQL\ProtocolParser::STATE_OK; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|