I’m working on a message system where users can send messages to eachother. But now I want to check if a username exists when sending the message. I’m developing this on symfony 2.
I went to the IRC channel of them and they told me to use the UniqueConstraint of Doctrine, but it does exactly the opposite of what I want it to do. I want to check if a username exists, if yes the user can send it.
So is there any way to “turnaround” the behaviour ?
You
SELECTyour username, for example throughcreateQueryand the proper DQL statement … and if the result set holds at least one user, then a user with this username exists.