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

Introduce Statement::executeQuery and Statement::executeStatement. #4607

Closed
beberlei opened this issue Apr 17, 2021 · 2 comments
Closed

Introduce Statement::executeQuery and Statement::executeStatement. #4607

beberlei opened this issue Apr 17, 2021 · 2 comments

Comments

@beberlei
Copy link
Member

Feature Request

Q A
New Feature yes
RFC no
BC Break no
Refs #4580

Summary

To differentiate between select and manipulation queries, the Statement should differentiate using two methods executeQuery() which returns a Result and executeStatement which returns the number of affected rows.

This was tackled in #4580 as a way to ensure forwards compatibility with the 3.x branch, but it also improves the API in the process.

In turn Statement::execute is also deprecated and gets removed in DBAL 4.0. You must replace the following code:

// old code
$sql = 'SELECT * FROM user';
$result = $connection->prepare($sql)->execute();

// new code
$sql = 'SELECT * FROM user';
$result = $connection->prepare($sql)->executeQuery();

and for manipulation or DDL statements:

// old code
$sql = 'UPDATE user SET disabled = 1';
$result = $connection->prepare($sql)->execute();

// new code
$sql = 'UPDATE user SET disabled = 1';
$result = $connection->prepare($sql)->executeStatement();
@beberlei
Copy link
Member Author

Fixed by upmerging #4580 in #4606

ChristophWurst added a commit to nextcloud/server that referenced this issue May 5, 2021
Because executeUpdate wasn't a great name. And in DBAL they also use
executeStatement more consistently now.

Ref doctrine/dbal#4607

Signed-off-by: Christoph Wurst <[email protected]>
@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

1 participant