@@ -221,7 +221,7 @@ public function startCommand($callback) {
221
221
222
222
public function setQuery ($ query ) {
223
223
$ this ->query = $ query ;
224
- $ this ->packetCallback = [$ this , "handleQuery " ];
224
+ $ this ->parseCallback = [$ this , "handleQuery " ];
225
225
}
226
226
227
227
public function setPrepare ($ query ) {
@@ -322,6 +322,7 @@ public function execute($stmtId, $query, &$params, $prebound, $data = []) {
322
322
$ this ->out [] = null ;
323
323
$ this ->deferreds [] = $ deferred ;
324
324
$ this ->sendPacket ($ payload );
325
+ // apparently LOAD DATA LOCAL INFILE requests are not supported via prepared statements
325
326
$ this ->packetCallback = [$ this , "handleExecute " ];
326
327
});
327
328
return $ deferred ->promise (); // do not use $this->startCommand(), that might unexpectedly reset the seqId!
@@ -543,11 +544,32 @@ private function handleLocalInfileRequest($packet) {
543
544
544
545
/** @see 14.6.4.1.1 Text Resultset */
545
546
private function handleQuery ($ packet ) {
547
+ switch (\ord ($ packet )) {
548
+ case self ::OK_PACKET :
549
+ $ this ->parseOk ($ packet );
550
+ if ($ this ->connInfo ->statusFlags & StatusFlags::SERVER_MORE_RESULTS_EXISTS ) {
551
+ $ this ->getDeferred ()->succeed (new ResultSet ($ this ->connInfo , $ result = new ResultProxy ));
552
+ $ this ->result = $ result ;
553
+ $ result ->updateState (ResultProxy::COLUMNS_FETCHED );
554
+ $ this ->successfulResultsetFetch ();
555
+ } else {
556
+ $ this ->getDeferred ()->succeed ($ this ->getConnInfo ());
557
+ $ this ->ready ();
558
+ }
559
+ return ;
560
+ case self ::LOCAL_INFILE_REQUEST :
561
+ $ this ->handleLocalInfileRequest ($ packet );
562
+ return ;
563
+ case self ::ERR_PACKET :
564
+ $ this ->handleError ($ packet );
565
+ return ;
566
+ }
567
+
546
568
$ this ->parseCallback = [$ this , "handleTextColumnDefinition " ];
547
569
$ this ->getDeferred ()->succeed (new ResultSet ($ this ->connInfo , $ result = new ResultProxy ));
548
570
/* we need to succeed before assigning vars, so that a when() handler won't have a partial result available */
549
571
$ this ->result = $ result ;
550
- $ this -> result ->setColumns (DataTypes::decodeInt ($ packet ));
572
+ $ result ->setColumns (DataTypes::decodeInt ($ packet ));
551
573
}
552
574
553
575
/** @see 14.7.1 Binary Protocol Resultset */
@@ -556,7 +578,7 @@ private function handleExecute($packet) {
556
578
$ this ->getDeferred ()->succeed (new ResultSet ($ this ->connInfo , $ result = new ResultProxy ));
557
579
/* we need to succeed before assigning vars, so that a when() handler won't have a partial result available */
558
580
$ this ->result = $ result ;
559
- $ this -> result ->setColumns (ord ($ packet ));
581
+ $ result ->setColumns (ord ($ packet ));
560
582
}
561
583
562
584
private function handleFieldList ($ packet ) {
@@ -619,9 +641,9 @@ private function prepareParams($packet) {
619
641
private function prepareFields ($ packet ) {
620
642
if (!$ this ->result ->columnsToFetch --) {
621
643
$ this ->parseCallback = null ;
622
- $ this ->result ->updateState (ResultProxy::COLUMNS_FETCHED );
623
644
$ this ->query = null ;
624
645
$ this ->ready ();
646
+ $ this ->result ->updateState (ResultProxy::COLUMNS_FETCHED );
625
647
626
648
return ;
627
649
}
@@ -694,17 +716,17 @@ private function parseColumnDefinition($packet) {
694
716
private function successfulResultsetFetch () {
695
717
$ deferred = &$ this ->result ->next ;
696
718
if ($ this ->connInfo ->statusFlags & StatusFlags::SERVER_MORE_RESULTS_EXISTS ) {
697
- $ this ->packetCallback = [$ this , "handleQuery " ];
719
+ $ this ->parseCallback = [$ this , "handleQuery " ];
698
720
$ this ->deferreds [] = $ deferred ?: $ deferred = new Deferred ;
699
721
} else {
700
722
if (!$ deferred ) {
701
723
$ deferred = new Deferred ;
702
724
}
703
725
$ deferred ->succeed ();
726
+ $ this ->parseCallback = null ;
727
+ $ this ->query = null ;
728
+ $ this ->ready ();
704
729
}
705
- $ this ->parseCallback = null ;
706
- $ this ->query = null ;
707
- $ this ->ready ();
708
730
$ this ->result ->updateState (ResultProxy::ROWS_FETCHED );
709
731
}
710
732
@@ -1090,9 +1112,6 @@ private function parsePayload($packet) {
1090
1112
case self ::OK_PACKET :
1091
1113
$ this ->handleOk ($ packet );
1092
1114
break ;
1093
- case self ::LOCAL_INFILE_REQUEST :
1094
- $ this ->handleLocalInfileRequest ($ packet );
1095
- break ;
1096
1115
case self ::ERR_PACKET :
1097
1116
$ this ->handleError ($ packet );
1098
1117
break ;
0 commit comments