18
18
use CleverAge \ProcessBundle \Model \IterableTaskInterface ;
19
19
use CleverAge \ProcessBundle \Model \ProcessState ;
20
20
use Doctrine \DBAL \Connection ;
21
- use Doctrine \DBAL \Driver \PDOStatement ;
22
- use Doctrine \DBAL \Driver \ResultStatement ;
21
+ use Doctrine \DBAL \Result ;
23
22
use Doctrine \Persistence \ManagerRegistry ;
24
23
use Psr \Log \LoggerInterface ;
25
24
use Psr \Log \LogLevel ;
30
29
*/
31
30
class DatabaseReaderTask extends AbstractConfigurableTask implements IterableTaskInterface, FinalizableTaskInterface
32
31
{
33
- protected ?PDOStatement $ statement = null ;
32
+ protected ?Result $ statement = null ;
34
33
35
34
protected mixed $ nextItem = null ;
36
35
@@ -51,7 +50,7 @@ public function next(ProcessState $state): bool
51
50
return false ;
52
51
}
53
52
54
- $ this ->nextItem = $ this ->statement ->fetch ();
53
+ $ this ->nextItem = $ this ->statement ->fetchAssociative ();
55
54
56
55
return (bool ) $ this ->nextItem ;
57
56
}
@@ -68,7 +67,7 @@ public function execute(ProcessState $state): void
68
67
$ result = $ this ->nextItem ;
69
68
$ this ->nextItem = null ;
70
69
} else {
71
- $ result = $ this ->statement ->fetch ();
70
+ $ result = $ this ->statement ->fetchAssociative ();
72
71
}
73
72
74
73
// Handle empty results
@@ -88,7 +87,7 @@ public function execute(ProcessState $state): void
88
87
$ i = 0 ;
89
88
while ($ result !== false && $ i ++ < $ options ['paginate ' ]) {
90
89
$ results [] = $ result ;
91
- $ result = $ this ->statement ->fetch ();
90
+ $ result = $ this ->statement ->fetchAssociative ();
92
91
}
93
92
$ state ->setOutput ($ results );
94
93
} else {
@@ -98,12 +97,10 @@ public function execute(ProcessState $state): void
98
97
99
98
public function finalize (ProcessState $ state ): void
100
99
{
101
- if ($ this ->statement ) {
102
- $ this ->statement ->closeCursor ();
103
- }
100
+ $ this ->statement ?->free();
104
101
}
105
102
106
- protected function initializeStatement (ProcessState $ state ): ResultStatement
103
+ protected function initializeStatement (ProcessState $ state ): Result
107
104
{
108
105
$ options = $ this ->getOptions ($ state );
109
106
$ connection = $ this ->getConnection ($ state );
0 commit comments