@@ -530,15 +530,29 @@ function ($matches) use ($params, &$numParams, &$i, &$j) {
530
530
531
531
/**
532
532
* @param DbalConnection|Connection $connection
533
+ *
534
+ * @return DbalResult|int<0, max>
535
+ *
536
+ * @deprecated Expression::execute() is deprecated and will be removed in v4.0, use Expression::executeQuery() or Expression::executeStatement() instead
533
537
*/
534
- public function execute (object $ connection = null ): DbalResult
538
+ public function execute (object $ connection = null , bool $ fromExecuteStatement = null )
535
539
{
536
540
if ($ connection === null ) {
537
541
$ connection = $ this ->connection ;
538
542
}
539
543
544
+ if ($ fromExecuteStatement === null ) {
545
+ 'trigger_error ' ('Method is deprecated. Use executeQuery() or executeStatement() instead ' , \E_USER_DEPRECATED );
546
+
547
+ $ fromExecuteStatement = false ;
548
+ }
549
+
540
550
if (!$ connection instanceof DbalConnection) {
541
- return $ connection ->execute ($ this );
551
+ if ($ fromExecuteStatement ) {
552
+ return $ connection ->executeStatement ($ this );
553
+ }
554
+
555
+ return $ connection ->executeQuery ($ this );
542
556
}
543
557
544
558
[$ query , $ params ] = $ this ->updateRenderBeforeExecute ($ this ->render ());
@@ -597,7 +611,11 @@ public function execute(object $connection = null): DbalResult
597
611
}
598
612
}
599
613
600
- $ result = $ statement ->execute (); // @phpstan-ignore-line
614
+ if ($ fromExecuteStatement ) {
615
+ $ result = $ statement ->executeStatement ();
616
+ } else {
617
+ $ result = $ statement ->executeQuery ();
618
+ }
601
619
602
620
return $ result ;
603
621
} catch (DbalException $ e ) {
@@ -617,6 +635,24 @@ public function execute(object $connection = null): DbalResult
617
635
}
618
636
}
619
637
638
+ /**
639
+ * @param DbalConnection|Connection $connection
640
+ */
641
+ public function executeQuery (object $ connection = null ): DbalResult
642
+ {
643
+ return $ this ->execute ($ connection , false ); // @phpstan-ignore-line
644
+ }
645
+
646
+ /**
647
+ * @param DbalConnection|Connection $connection
648
+ *
649
+ * @phpstan-return int<0, max>
650
+ */
651
+ public function executeStatement (object $ connection = null ): int
652
+ {
653
+ return $ this ->execute ($ connection , true ); // @phpstan-ignore-line
654
+ }
655
+
620
656
// {{{ Result Querying
621
657
622
658
/**
@@ -648,7 +684,7 @@ public function getRowsIterator(): \Traversable
648
684
{
649
685
// DbalResult::iterateAssociative() is broken with streams with Oracle database
650
686
// https://github.com/doctrine/dbal/issues/5002
651
- $ iterator = $ this ->execute ()->iterateAssociative ();
687
+ $ iterator = $ this ->executeQuery ()->iterateAssociative ();
652
688
653
689
foreach ($ iterator as $ row ) {
654
690
yield array_map (function ($ v ) {
@@ -666,7 +702,7 @@ public function getRows(): array
666
702
{
667
703
// DbalResult::fetchAllAssociative() is broken with streams with Oracle database
668
704
// https://github.com/doctrine/dbal/issues/5002
669
- $ result = $ this ->execute ();
705
+ $ result = $ this ->executeQuery ();
670
706
671
707
$ rows = [];
672
708
while (($ row = $ result ->fetchAssociative ()) !== false ) {
@@ -685,7 +721,7 @@ public function getRows(): array
685
721
*/
686
722
public function getRow (): ?array
687
723
{
688
- $ row = $ this ->execute ()->fetchAssociative ();
724
+ $ row = $ this ->executeQuery ()->fetchAssociative ();
689
725
690
726
if ($ row === false ) {
691
727
return null ;
0 commit comments