I am running a script in Symfony2/Doctrine2 project.
And I receive the Doctrine\DBAL\Exception\UniqueConstraintViolationException exception.
An exception occurred while executing
'INSERT INTO user (name, created_at) VALUES (?, ?)'
with params ["Gaurav" "2016-07-31 17:10:54"]:
SQLSTATE[23000]: Integrity constraint violation:
1062 Duplicate entry 'Gaurav' for key 'UNIQ_8C9F36105E237E06'
Any idea, how I can avoid this?
I have been using Repository findByOne() and then updating the record. It still generates an SQL query.
I found the following post. But I am not sure, if this is necessary.
Please advise.