From 2fe737f19309b4b0aac886935e8af6d1f9123b26 Mon Sep 17 00:00:00 2001 From: PrinsFrank <25006490+PrinsFrank@users.noreply.github.com> Date: Tue, 16 Jul 2024 09:27:58 +0200 Subject: [PATCH] Fix update/delete aliases in documentation (#6470) | Q | A |------------- | ----------- | Type | bug/improvement | Fixed issues | Incorrect & inconsistent QueryBuilder documentation for aliases in update/delete #### Summary In #6394 the documentation was partially updated to remove aliases for the documentation for the update method, as the separate parameter for it was removed in the upgrade from 3.x to 4.x. Inline aliasing is still possible, and I suspect this was the reason the extra parameter was removed. ( `->update('users alias1', 'alias2')`)? This PR readds the alias to the documentation for the occurences in the linked PR, and also updates the other occurences in docblocks + the online documentation. --- docs/en/reference/query-builder.rst | 2 +- src/Query/QueryBuilder.php | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/en/reference/query-builder.rst b/docs/en/reference/query-builder.rst index b15a75f67ac..ecfb5337663 100644 --- a/docs/en/reference/query-builder.rst +++ b/docs/en/reference/query-builder.rst @@ -309,7 +309,7 @@ user-input: update('users', 'u') + ->update('users u') ->set('u.logins', 'u.logins + 1') ->set('u.last_login', '?') ->setParameter(0, $userInputLastLogin) diff --git a/src/Query/QueryBuilder.php b/src/Query/QueryBuilder.php index 9f4eb5a30a4..c6d33448ab3 100644 --- a/src/Query/QueryBuilder.php +++ b/src/Query/QueryBuilder.php @@ -580,8 +580,8 @@ public function addSelect(string $expression, string ...$expressions): self * * * $qb = $conn->createQueryBuilder() - * ->delete('users') - * ->where('users.id = :user_id') + * ->delete('users u') + * ->where('u.id = :user_id') * ->setParameter(':user_id', 1); * * @@ -606,9 +606,9 @@ public function delete(string $table): self * * * $qb = $conn->createQueryBuilder() - * ->update('counters') - * ->set('counters.value', 'counters.value + 1') - * ->where('counters.id = ?'); + * ->update('counters c') + * ->set('c.value', 'c.value + 1') + * ->where('c.id = ?'); * * * @param string $table The table whose rows are subject to the update. @@ -785,7 +785,7 @@ public function rightJoin(string $fromAlias, string $join, string $alias, ?strin * * * $qb = $conn->createQueryBuilder() - * ->update('counters', 'c') + * ->update('counters c') * ->set('c.value', 'c.value + 1') * ->where('c.id = ?'); * @@ -821,7 +821,7 @@ public function set(string $key, string $value): self * $or->add($qb->expr()->eq('c.id', 1)); * $or->add($qb->expr()->eq('c.id', 2)); * - * $qb->update('counters', 'c') + * $qb->update('counters c') * ->set('c.value', 'c.value + 1') * ->where($or); *