I have table with two columns: price and constant.
I would like to run update on all entries in table to update price based on constant * coefficient.
How could I do such query?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do that with a DQL query:
You can also do that with raw SQL:
You could also add a listener on the preUpdate & prePersist doctrine event, so that these values are updated automatically.
See http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#preupdate for an example.
So that each time you save your entity, it will update the related field automatically.