1818use CleverAge \ProcessBundle \Model \IterableTaskInterface ;
1919use CleverAge \ProcessBundle \Model \ProcessState ;
2020use Doctrine \DBAL \Connection ;
21- use Doctrine \DBAL \Driver \PDOStatement ;
22- use Doctrine \DBAL \Driver \ResultStatement ;
21+ use Doctrine \DBAL \Result ;
2322use Doctrine \Persistence \ManagerRegistry ;
2423use Psr \Log \LoggerInterface ;
2524use Psr \Log \LogLevel ;
3029 */
3130class DatabaseReaderTask extends AbstractConfigurableTask implements IterableTaskInterface, FinalizableTaskInterface
3231{
33- protected ?PDOStatement $ statement = null ;
32+ protected ?Result $ statement = null ;
3433
3534 protected mixed $ nextItem = null ;
3635
@@ -51,7 +50,7 @@ public function next(ProcessState $state): bool
5150 return false ;
5251 }
5352
54- $ this ->nextItem = $ this ->statement ->fetch ();
53+ $ this ->nextItem = $ this ->statement ->fetchAssociative ();
5554
5655 return (bool ) $ this ->nextItem ;
5756 }
@@ -68,7 +67,7 @@ public function execute(ProcessState $state): void
6867 $ result = $ this ->nextItem ;
6968 $ this ->nextItem = null ;
7069 } else {
71- $ result = $ this ->statement ->fetch ();
70+ $ result = $ this ->statement ->fetchAssociative ();
7271 }
7372
7473 // Handle empty results
@@ -88,7 +87,7 @@ public function execute(ProcessState $state): void
8887 $ i = 0 ;
8988 while ($ result !== false && $ i ++ < $ options ['paginate ' ]) {
9089 $ results [] = $ result ;
91- $ result = $ this ->statement ->fetch ();
90+ $ result = $ this ->statement ->fetchAssociative ();
9291 }
9392 $ state ->setOutput ($ results );
9493 } else {
@@ -98,12 +97,10 @@ public function execute(ProcessState $state): void
9897
9998 public function finalize (ProcessState $ state ): void
10099 {
101- if ($ this ->statement ) {
102- $ this ->statement ->closeCursor ();
103- }
100+ $ this ->statement ?->free();
104101 }
105102
106- protected function initializeStatement (ProcessState $ state ): ResultStatement
103+ protected function initializeStatement (ProcessState $ state ): Result
107104 {
108105 $ options = $ this ->getOptions ($ state );
109106 $ connection = $ this ->getConnection ($ state );
0 commit comments