@@ -533,6 +533,14 @@ public function batchInsert($attributes = null){
533533 return self ::flushBatchInsert ();
534534 }
535535
536+ /**
537+ * resetting batch insert
538+ */
539+ public static function resetBatchInsert (){
540+ self ::$ batchInsertQueue = 0 ;
541+ self ::$ batchInsertCommand ->document = [];
542+ }
543+
536544 /**
537545 * execute batch insert operations in queue and reset anything
538546 * this method is not continue when not exists any insert operations in queue
@@ -542,19 +550,10 @@ public static function flushBatchInsert(){
542550 if (self ::$ batchInsertQueue === 0 )
543551 return ;
544552 $ result = self ::$ batchInsertCommand ->executeBatch (static ::collectionName ());
545- self ::$ batchInsertQueue = 0 ;
546- self ::$ batchInsertCommand ->document = [];
553+ self ::resetBatchInsert ();
547554 return $ result ;
548555 }
549556
550- /**
551- * resetting queue
552- */
553- public static function resetBatchInsert (){
554- self ::$ batchInsertQueue = 0 ;
555- self ::$ batchInsertCommand ->document = [];
556- }
557-
558557 /**
559558 * checking if current ActiveRecord class has documents in queue for update
560559 * @return bool
@@ -612,6 +611,14 @@ public static function batchUpdateAll($attributes, $condition = [], $options = [
612611 return self ::flushBatchUpdate ();
613612 }
614613
614+ /**
615+ * resetting batch update
616+ */
617+ public static function resetBatchUpdate (){
618+ self ::$ batchUpdateQueue = 0 ;
619+ self ::$ batchUpdateCommand ->document = [];
620+ }
621+
615622 /**
616623 * execute batch update operations in queue and reset anything
617624 * this method is not continue when not exists any update operations in queue
@@ -621,8 +628,7 @@ public static function flushBatchUpdate(){
621628 if (self ::$ batchUpdateQueue === 0 )
622629 return ;
623630 $ result = self ::$ batchUpdateCommand ->executeBatch (static ::collectionName ());
624- self ::$ batchUpdateQueue = 0 ;
625- self ::$ batchUpdateCommand ->document = [];
631+ self ::resetBatchUpdate ();
626632 return $ result ;
627633 }
628634
@@ -684,6 +690,14 @@ public function batchDeleteAll($condition = [], $options = []){
684690 return self ::flushBatchDelete ();
685691 }
686692
693+ /**
694+ * resetting batch delete
695+ */
696+ public static function resetBatchDelete (){
697+ self ::$ batchDeleteQueue = 0 ;
698+ self ::$ batchDeleteCommand ->document = [];
699+ }
700+
687701 /**
688702 * execute batch delete operations in queue and reset anything
689703 * this method is not continue when not exists any delete operations in queue
@@ -693,8 +707,7 @@ public static function flushBatchDelete(){
693707 if (self ::$ batchDeleteQueue === 0 )
694708 return ;
695709 $ result = self ::$ batchDeleteCommand ->executeBatch (static ::collectionName ());
696- self ::$ batchDeleteQueue = 0 ;
697- self ::$ batchDeleteCommand ->document = [];
710+ self ::resetBatchDelete ();
698711 return $ result ;
699712 }
700713
0 commit comments