mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #1434] convertToDatabaseValueSQL with $columnName #9492
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/1434
State: closed
Merged: No
Goal:
I want to be able to atomically increment a property such that
$stock->setQuantityDelta(2);will render into an SQL such asUPDATE stock SET quantity = quantity+? WHERE id = ?;.I would like to accomplish this without using
DQLevery time it is necessary hence I implemented a custom Doctrine2 type which can accomplish this -- with support from this PR.Changes:
\Doctrine\ORM\Persisters\BasicEntityPersister::updateTablenow passes the column name to\Doctrine\DBAL\Types\Type::convertToDatabaseValueSQL(PR) to be used by the concrete type instance (ex.: @mihai-stancu/doctrine-types-extra:\MS\Doctrine\DBAL\Types\DeltaType).