Vince V.
Vince V.

Reputation: 3143

Check if user exists (and go on...)

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 ?

Upvotes: 0

Views: 911

Answers (1)

Raffael
Raffael

Reputation: 20045

I want to check if a username exists, if yes ...

You SELECT your username, for example through createQuery and the proper DQL statement ... and if the result set holds at least one user, then a user with this username exists.

Upvotes: 1

Related Questions