1

Since the release of Doctrine DBAL 2.13 deprecations have been added as stated here.

While the old way of fetching results is something like this:

$statement->execute();
while (($row = $statement->fetch()) !== false) {
}

The new way goes like this:

$result = $statement->execute();
while (($row = $result->fetchAssociative()) !== false) {
}

I'd like to update my code to be prepared for doctrine/dbal 3.0, but $statement->execute() doesn't return a resultset but just a boolean value, so there's nothing to iterate, even so the release notes state:

DBAL 3.0 extracts all fetch-methods from the Statement API and moved them to a new Result API that is returned from Statement::execute. We have backported this API to 2.13

So does this mean the backport failed or am I missing something?

Select0r
  • 12,234
  • 11
  • 45
  • 68
  • Filed a bugreport (https://github.com/doctrine/dbal/issues/4569), seems it has already been fixed in 2.13.1 (which needs to be released as of now). – Select0r Apr 16 '21 at 07:19

1 Answers1

2

Update to doctrine/dbal 2.13.1 (released 4/2021) and use:

$result = $statement->executeQuery();
while (($row = $result->fetchAssociative()) !== false) {
}

Note that executeQuery() should be used to get the Result-object as execute() is now also deprecated. (this is also missing in the release notes)

Select0r
  • 12,234
  • 11
  • 45
  • 68