Skip to content

Commit

Permalink
Fix update/delete aliases in documentation (#6470)
Browse files Browse the repository at this point in the history
<!-- Fill in the relevant information below to help triage your pull
request. -->

|      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.
  • Loading branch information
PrinsFrank committed Jul 16, 2024
1 parent 9042447 commit 2fe737f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/en/reference/query-builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ user-input:
<?php
$queryBuilder
->update('users', 'u')
->update('users u')
->set('u.logins', 'u.logins + 1')
->set('u.last_login', '?')
->setParameter(0, $userInputLastLogin)
Expand Down
14 changes: 7 additions & 7 deletions src/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,8 @@ public function addSelect(string $expression, string ...$expressions): self
*
* <code>
* $qb = $conn->createQueryBuilder()
* ->delete('users')
* ->where('users.id = :user_id')
* ->delete('users u')
* ->where('u.id = :user_id')
* ->setParameter(':user_id', 1);
* </code>
*
Expand All @@ -606,9 +606,9 @@ public function delete(string $table): self
*
* <code>
* $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 = ?');
* </code>
*
* @param string $table The table whose rows are subject to the update.
Expand Down Expand Up @@ -785,7 +785,7 @@ public function rightJoin(string $fromAlias, string $join, string $alias, ?strin
*
* <code>
* $qb = $conn->createQueryBuilder()
* ->update('counters', 'c')
* ->update('counters c')
* ->set('c.value', 'c.value + 1')
* ->where('c.id = ?');
* </code>
Expand Down Expand Up @@ -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);
* </code>
Expand Down

0 comments on commit 2fe737f

Please sign in to comment.