Task/Database/DatabaseReaderTask.php
public function execute(ProcessState $state)
    {
        $options = $this->getOptions($state);
        if (!$this->statement) {
            $this->statement = $this->initializeStatement($state);
        }

        // Check if the next item has been stored by the next() call
        if (null !== $this->nextItem) {
            $result = $this->nextItem;
            $this->nextItem = null;
        } else {
            $result = $this->statement->fetch();
        }

        // Handle empty results
        if (false === $result) {
            $logContext = ['options' => $options];
            $this->logger->log($options['empty_log_level'], 'Empty resultset for query', $logContext);
            $state->setSkipped(true);
            $this->statement = null;

            return;
        }

        if (null !== $options['paginate']) {
            $results = [];
            $i = 0;
            while (false !== $result && $i++ < $options['paginate']) {
                $results[] = $result;
                $result = $this->statement->fetch();
            }
            $state->setOutput($results);
        } else {
            $state->setOutput($result);
        }
    }
public function execute(ProcessState $state)
    {
        $options = $this->getOptions($state);
        if (!$this->statement) {
            $this->statement = $this->initializeStatement($state);
        }

        // Check if the next item has been stored by the next() call
        if (null !== $this->nextItem) {
            $result = $this->nextItem;
            $this->nextItem = null;
        } else {
            $result = $this->statement->fetch();
        }

        // Handle empty results
        if (false === $result) {
            $logContext = ['options' => $options];
            $this->logger->log($options['empty_log_level'], 'Empty resultset for query', $logContext);
            $state->setSkipped(true);
            $this->statement = null;

            return;
        }

        if (null !== $options['paginate']) {
            $results = [];
            $i = 0;
            while (false !== $result && $i++ < $options['paginate']) {
                $results[] = $result;
                $result = $this->statement->fetch();
            }
            $state->setOutput($results);
        } else {
            $state->setOutput($result);
        }
    }
@param ProcessState $state

@throws \InvalidArgumentException
@throws \Symfony\Component\OptionsResolver\Exception\ExceptionInterface
@throws \Doctrine\DBAL\DBALException