@@ -81,21 +81,43 @@ public function getResponse($checkResponse = true)
81
81
return '' ;
82
82
}
83
83
$ dataLength = unpack ('L ' , $ header [0 ] . $ header [1 ] . $ header [2 ] . chr (0 ))[1 ];
84
+ $ isMaxDataLength = $ dataLength === $ this ->binaryDataMaxLength ;
84
85
85
86
$ result = $ this ->socket ->readFromSocket ($ dataLength );
86
87
if (true === $ checkResponse ) {
87
- $ this ->isWriteSuccessful ($ result );
88
+ $ this ->isWriteSuccessful ($ result , $ isMaxDataLength );
89
+ }
90
+
91
+ //https://dev.mysql.com/doc/internals/en/sending-more-than-16mbyte.html
92
+ while ($ isMaxDataLength ) {
93
+ $ header = $ this ->socket ->readFromSocket (4 );
94
+ if ('' === $ header ) {
95
+ return $ result ;
96
+ }
97
+ $ dataLength = unpack ('L ' , $ header [0 ] . $ header [1 ] . $ header [2 ] . chr (0 ))[1 ];
98
+ $ isMaxDataLength = $ dataLength === $ this ->binaryDataMaxLength ;
99
+
100
+ $ next_result = $ this ->socket ->readFromSocket ($ dataLength );
101
+ if (true === $ checkResponse ) {
102
+ $ this ->isWriteSuccessful ($ next_result , $ isMaxDataLength );
103
+ }
104
+ $ result .= $ next_result ;
88
105
}
89
106
90
107
return $ result ;
91
108
}
92
109
93
110
/**
94
111
* @param string $data
112
+ * @param bool $isMaxDataLength
113
+ *
95
114
* @throws BinLogException
96
115
*/
97
- private function isWriteSuccessful ($ data )
116
+ private function isWriteSuccessful ($ data, $ isMaxDataLength = false )
98
117
{
118
+ if ($ isMaxDataLength ) {
119
+ return ;
120
+ }
99
121
$ head = ord ($ data [0 ]);
100
122
if (!in_array ($ head , $ this ->packageOkHeader , true )) {
101
123
$ errorCode = unpack ('v ' , $ data [1 ] . $ data [2 ])[1 ];
0 commit comments