Skip to content

Commit

Permalink
minor #18429 Fix doctrine/dbal deprecation using `Statement::execut…
Browse files Browse the repository at this point in the history
…eQuery` (vinceAmstoutz)

This PR was submitted for the 6.3 branch but it was squashed and merged into the 6.2 branch instead.

Discussion
----------

Fix `doctrine/dbal` deprecation using `Statement::executeQuery`

Deprecation warning when `doctrine/dbal >= 3.4.*`.

In Symfony docs,executeQuery() is mentionned here : [Querying with SQL](https://symfony.com/doc/current/doctrine.html#querying-with-sql).

But since `3.4.*` passing parameters to `Statement::execute*()` functions is deprecated by `doctrine/dbal` with this warning:
`User Deprecated: Passing $params to Statement::executeQuery() is deprecated. Bind parameters using Statement::bindParam() or Statement::bindValue() instead. (Statement.php:212 called by User.php:40, doctrine/dbal#5556, package doctrine/dbal)`.

I've already ask in the [DBAL PR concerned](doctrine/dbal#5556 (comment)) how to use `executeQuery` from now on.

![image](https://github.com/symfony/symfony-docs/assets/46444652/e0b6938b-4f67-474a-a8f5-5f565b04e5b4)
[(in the same PR)](doctrine/dbal#5556 (comment))

So, after having tested it in a prod project, I propose an update of the doc in this sense.

Thanks again `@derrabus` 🙏

Commits
-------

5c8154b Fix `doctrine/dbal` deprecation using `Statement::executeQuery`
  • Loading branch information
OskarStark committed Jun 19, 2023
2 parents c1645f4 + 5c8154b commit 8eeba23
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doctrine.rst
Expand Up @@ -998,8 +998,8 @@ In addition, you can query directly with SQL if you need to::
WHERE p.price > :price
ORDER BY p.price ASC
';
$stmt = $conn->prepare($sql);
$resultSet = $stmt->executeQuery(['price' => $price]);

$resultSet = $conn->executeQuery($sql, ['price' => $price]);

// returns an array of arrays (i.e. a raw data set)
return $resultSet->fetchAllAssociative();
Expand Down

0 comments on commit 8eeba23

Please sign in to comment.