Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Statement::fetch* methods in favor of Result::fetch* counterparts #4554

Closed
beberlei opened this issue Mar 27, 2021 · 6 comments
Closed
Assignees
Milestone

Comments

@beberlei
Copy link
Member

beberlei commented Mar 27, 2021

Deprecation

Summary

Deprecate all new Statement::fetch* methods that should be called from a Result instead. The Result is returned as an object from Statement::execute. Work on the forward compatibility for the Result interface was done in #4529.

Old code

$statement = $connection->prepare('SELECT * FROM tbl');
$statement->execute();

$rows = $statement->fetchAllAssociative();

New code

$statement = $connection->prepare('SELECT * FROM tbl');
$result = $statement->execute();

$rows = $result->fetchAllAssociative();
@beberlei beberlei added this to the 2.13.0 milestone Mar 27, 2021
@beberlei beberlei self-assigned this Mar 27, 2021
beberlei added a commit to beberlei/dbal that referenced this issue Mar 27, 2021
beberlei added a commit to beberlei/dbal that referenced this issue Mar 27, 2021
beberlei added a commit to beberlei/dbal that referenced this issue Mar 28, 2021
beberlei added a commit to beberlei/dbal that referenced this issue Mar 28, 2021
beberlei added a commit that referenced this issue Mar 28, 2021
[GH-4554] Deprecate all Statement::fetch* in favor of Result::fetch*
@beberlei
Copy link
Member Author

Merged #4555

@msvrtan
Copy link

msvrtan commented Apr 8, 2021

@beberlei you deprecated them but $statement->execute(); returns true for me, so I cant use

$statement = $connection->prepare('SELECT * FROM tbl');
$result = $statement->execute();

$rows = $result->fetchAllAssociative();

Not sure if this was desired behaviour, if I'm in some kind of a limbo

doctrine/annotations                 1.12.1    Docblock Annotations Parser
doctrine/cache                       1.10.2    PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.
doctrine/collections                 1.6.7     PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                      3.1.2     PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, proxies and much more.
doctrine/data-fixtures               1.5.0     Data Fixtures for all Doctrine Object Managers
doctrine/dbal                        2.13.0    Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/deprecations                v0.5.3    A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.
doctrine/doctrine-bundle             2.3.1     Symfony DoctrineBundle
doctrine/doctrine-fixtures-bundle    3.4.0     Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle  3.1.0     Symfony DoctrineMigrationsBundle
doctrine/event-manager               1.1.1     The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector                   2.0.3     PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.
doctrine/instantiator                1.4.0     A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                       1.2.1     PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                  3.1.1     PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is a very easy to use and a ...
doctrine/orm                         2.8.4     Object-Relational-Mapper for PHP
doctrine/persistence                 2.1.0     The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.
doctrine/sql-formatter               1.1.1     a PHP SQL highlighting library

Just as a notice, I'm unable to upgrade to doctrine/dbal 3 as doctrine migrations 3.1 dont support it

@jlherren
Copy link

@msvrtan and all others having this issue, see #4569. A fix is already merged and will likely be in 2.13.1.

@COil
Copy link

COil commented Apr 20, 2021

I had some problems some weeks ago fixing those deprecations. Now everything is OK. Having the GitHub issue link in the deprecation is really nice. Thanks, @beberlei 🙂

@fmonts
Copy link

fmonts commented Apr 22, 2021

Why nobody likes the native PHP PDO structure and every framework wants to change it and use a different one 😅 hard to understand...

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants